-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
4,884 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/**/*.js | ||
|
||
zendesk/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"extends": ["plugin:@typescript-eslint/recommended", "prettier", "plugin:prettier/recommended"], | ||
"plugins": ["@typescript-eslint", "prettier", "unused-imports", "notice", "import"], | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"rules": { | ||
"curly": "warn", | ||
"dot-location": "warn", | ||
"eqeqeq": "error", | ||
"prettier/prettier": "warn", | ||
"unused-imports/no-unused-imports": "warn", | ||
"no-else-return": "warn", | ||
"no-lonely-if": "warn", | ||
"no-inner-declarations": "off", | ||
"no-unused-vars": "off", | ||
"no-useless-computed-key": "warn", | ||
"no-useless-return": "warn", | ||
"no-var": "warn", | ||
"object-shorthand": ["warn", "always"], | ||
"prefer-arrow-callback": "warn", | ||
"prefer-const": "warn", | ||
"prefer-destructuring": ["warn", { "AssignmentExpression": { "array": true } }], | ||
"prefer-object-spread": "warn", | ||
"prefer-template": "warn", | ||
"spaced-comment": ["warn", "always", { "markers": ["/"] }], | ||
"yoda": "warn", | ||
"import/order": [ | ||
"warn", | ||
{ | ||
"newlines-between": "always", | ||
"groups": ["type", "builtin", "external", "internal", ["parent", "sibling"], "index"], | ||
"pathGroupsExcludedImportTypes": ["builtin"], | ||
"pathGroups": [ | ||
{ | ||
"pattern": "models{/**,}", | ||
"group": "internal" | ||
}, | ||
{ | ||
"pattern": "+(types){/**,}", | ||
"group": "internal", | ||
"position": "after" | ||
} | ||
], | ||
"alphabetize": { | ||
"order": "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */, | ||
"caseInsensitive": true /* ignore case. Options: [true, false] */ | ||
} | ||
} | ||
], | ||
"@typescript-eslint/array-type": ["warn", { "default": "array-simple" }], | ||
"@typescript-eslint/ban-ts-comment": [ | ||
"warn", | ||
{ | ||
"ts-expect-error": "allow-with-description" | ||
} | ||
], | ||
"@typescript-eslint/ban-types": "warn", | ||
"@typescript-eslint/consistent-indexed-object-style": ["warn", "record"], | ||
"@typescript-eslint/consistent-type-definitions": ["warn", "interface"], | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"notice/notice": [ | ||
"error", | ||
{ | ||
"mustMatch": "Copyright \\(c\\) [0-9]{0,4}, Poozle, all rights reserved.", | ||
"template": "/** Copyright (c) <%= YEAR %>, Poozle, all rights reserved. **/\n\n" | ||
} | ||
] | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"overrides": [ | ||
{ | ||
"files": ["scripts/**/*"], | ||
"rules": { | ||
"@typescript-eslint/no-var-requires": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.pnp.* | ||
|
||
zendesk/ | ||
|
||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"arrowParens": "always", | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"requirePragma": false, | ||
"proseWrap": "preserve", | ||
"singleQuote": true, | ||
"formatOnSave": true, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"overrides": [ | ||
{ | ||
"files": ".prettierrc", | ||
"options": { | ||
"parser": "json" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Zendesk Readme | ||
|
||
This is the repository for the Zendesk integration, written in Typescript. | ||
|
||
### Prerequisites | ||
|
||
**To iterate on this connector, make sure to complete this prerequisites section.** | ||
|
||
#### Install dependencies | ||
|
||
From this integration directory, run the following command: | ||
|
||
```js | ||
yarn; | ||
``` | ||
|
||
This will install all the necessary dependencies for the integration. | ||
|
||
### Locally running the connector | ||
|
||
As we are still making the integration creation process better this is still a series of steps to test things out. We want to create a test suite to test certain key flows automatically. | ||
|
||
1. Run `yarn build` command to build the integration which will create a file `zendesk/index.js` which is the compiled | ||
version of the complete integration | ||
|
||
2. We already have a test file `public/test.js` where you can write multiple testcases to test the functionality of the integration. | ||
|
||
Examples: | ||
|
||
``` | ||
main('SPEC', {}) | ||
main('CHECK', { | ||
config: { | ||
// Pass credentials according to configuration | ||
} | ||
}) | ||
``` | ||
|
||
In case you need help reach us out in Slack. | ||
|
||
### Publishing a new version integration | ||
|
||
You can create a PR in our repo and we will take care of the rest. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"name": "@poozle/zendesk", | ||
"version": "0.1.0", | ||
"description": "zendesk extension for Poozle", | ||
"exports": { | ||
".": { | ||
"types": "./zendesk", | ||
"require": "./zendesk/index.js" | ||
} | ||
}, | ||
"package": "./zendesk/index.js", | ||
"types": "./zendesk", | ||
"files": [ | ||
"zendesk" | ||
], | ||
"scripts": { | ||
"build": "rimraf zendesk && npm run build:js", | ||
"build:js": "rollup -c", | ||
"lint": "eslint --ext js,ts,tsx src", | ||
"prettier": "prettier --config .prettierrc --write ." | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/preset-typescript": "^7.17.12", | ||
"@rollup/plugin-babel": "6.0.2", | ||
"@rollup/plugin-commonjs": "^23.0.2", | ||
"@rollup/plugin-json": "^5.0.1", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-replace": "^5.0.1", | ||
"@typescript-eslint/eslint-plugin": "5.48.2", | ||
"@typescript-eslint/parser": "5.48.2", | ||
"eslint": "^8.24.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-notice": "^0.9.10", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-unused-imports": "^2.0.0", | ||
"prettier": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^3.2.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.34.0", | ||
"typescript": "^4.7.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@poozle/engine-idk": "^0.1.44", | ||
"axios": "^1.4.0" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
const { main } = require("../zendesk/index"); | ||
|
||
async function run() { | ||
const response = await main("SPEC", {}); | ||
|
||
console.log(response); | ||
|
||
// const response = await main('RUN', { | ||
// config: { | ||
// | ||
// }, | ||
// path: '/collections', | ||
// method: 'GET', | ||
// params: { | ||
// queryParams: {}, | ||
// }, | ||
// }); | ||
|
||
// console.log(response); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** Copyright (c) 2022, Poozle, all rights reserved. **/ | ||
|
||
import { babel } from '@rollup/plugin-babel'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
import pkg from './package.json' assert { type: 'json' }; | ||
|
||
const extensions = ['.js', '.jsx', '.ts', '.tsx']; | ||
|
||
const plugins = [ | ||
json(), | ||
resolve({ extensions }), | ||
commonjs({ | ||
include: /\/node_modules\//, | ||
}), | ||
typescript(), | ||
babel({ | ||
extensions, | ||
presets: [], | ||
}), | ||
terser(), | ||
]; | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
external: [], | ||
output: [ | ||
{ | ||
file: pkg.package, | ||
sourcemap: true, | ||
format: 'cjs', | ||
exports: 'named', | ||
preserveModules: false, | ||
}, | ||
], | ||
plugins, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
import { Config } from '@poozle/engine-idk'; | ||
|
||
export const BASE_URL = 'GIVE_BASE_URL'; | ||
|
||
export interface Meta { | ||
previous: string; | ||
next: string; | ||
current: string; | ||
} | ||
|
||
export function getMetaParams(data: any, current_page: string): Meta { | ||
return { | ||
previous: '', | ||
current: current_page, | ||
next: data.end_time.toString() ?? '', | ||
}; | ||
} | ||
|
||
export function convertEpoc(epochTime: string) { | ||
const date = new Date(Number(epochTime)); | ||
return date.toISOString(); | ||
} | ||
|
||
export function convertDatetime(datetime: string) { | ||
const date = new Date(datetime); | ||
return date.getTime() / 1000; | ||
} | ||
|
||
export function getBaseUrl(config: Config): string { | ||
return `https://${config.zendesk_domain}/api/v2`; | ||
} | ||
|
||
function getPage(pageUrl: string, param: string) { | ||
const url = new URL(pageUrl); | ||
const params = new URLSearchParams(url.search); | ||
return params.get(param) ?? ''; | ||
} | ||
|
||
export function getPageMeta(data: any, current_page: string): Meta { | ||
return { | ||
previous: data.previous_page ? getPage(data.previous_page, 'page') : '', | ||
current: current_page, | ||
next: data.previous_page ? getPage(data.next_page, 'page') : '', | ||
}; | ||
} | ||
|
||
export function getCommentMeta(data: any, current_page: string): Meta { | ||
return { | ||
previous: data.previous_page ? getPage(data.previous_page, 'page') : '', | ||
current: current_page, | ||
next: data.previous_page ? getPage(data.next_page, 'page') : '', | ||
}; | ||
} |
Oops, something went wrong.