@code.store/arcxp-sdk-ts 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/abstract-api.d.ts +19 -0
- package/dist/api/abstract-api.js +33 -0
- package/dist/api/abstract-api.js.map +1 -0
- package/dist/api/author/index.d.ts +5 -0
- package/dist/api/author/index.js +15 -0
- package/dist/api/author/index.js.map +1 -0
- package/dist/api/author/types.js +2 -0
- package/dist/api/author/types.js.map +1 -0
- package/dist/api/draft/index.d.ts +5 -0
- package/dist/api/draft/index.js +15 -0
- package/dist/api/draft/index.js.map +1 -0
- package/dist/api/draft/types.js +3 -0
- package/dist/api/draft/types.js.map +1 -0
- package/dist/api/error.d.ts +10 -0
- package/dist/api/error.js +24 -0
- package/dist/api/error.js.map +1 -0
- package/dist/api/identity/index.d.ts +6 -0
- package/dist/api/identity/index.js +15 -0
- package/dist/api/identity/index.js.map +1 -0
- package/dist/api/identity/types.d.ts +58 -0
- package/dist/api/identity/types.js +3 -0
- package/dist/api/identity/types.js.map +1 -0
- package/dist/api/ifx/index.d.ts +18 -0
- package/dist/api/ifx/index.js +56 -0
- package/dist/api/ifx/index.js.map +1 -0
- package/dist/api/ifx/types.d.ts +24 -0
- package/dist/api/ifx/types.js +3 -0
- package/dist/api/ifx/types.js.map +1 -0
- package/dist/api/index.d.ts +22 -0
- package/dist/api/index.js +42 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/migration-center/index.d.ts +10 -0
- package/dist/api/migration-center/index.js +34 -0
- package/dist/api/migration-center/index.js.map +1 -0
- package/dist/api/migration-center/types.d.ts +166 -0
- package/dist/api/migration-center/types.js +40 -0
- package/dist/api/migration-center/types.js.map +1 -0
- package/dist/api/sales/index.d.ts +6 -0
- package/dist/api/sales/index.js +25 -0
- package/dist/api/sales/index.js.map +1 -0
- package/dist/api/sales/types.d.ts +68 -0
- package/dist/api/sales/types.js +3 -0
- package/dist/api/sales/types.js.map +1 -0
- package/dist/api/site/index.d.ts +7 -0
- package/dist/api/site/index.js +19 -0
- package/dist/api/site/index.js.map +1 -0
- package/dist/api/site/types.js +3 -0
- package/dist/api/site/types.js.map +1 -0
- package/dist/api/websked/index.d.ts +6 -0
- package/dist/api/websked/index.js +15 -0
- package/dist/api/websked/index.js.map +1 -0
- package/dist/api/websked/types.d.ts +7 -0
- package/dist/api/websked/types.js +3 -0
- package/dist/api/websked/types.js.map +1 -0
- package/dist/api/ws.client.d.ts +17 -0
- package/dist/api/ws.client.js +67 -0
- package/dist/api/ws.client.js.map +1 -0
- package/dist/content-elements/index.d.ts +137 -0
- package/dist/content-elements/index.js +112 -0
- package/dist/content-elements/index.js.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +0 -2
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/tests/api/basic.test.d.ts +1 -0
- package/dist/tests/api/basic.test.js +15 -0
- package/dist/tests/api/basic.test.js.map +1 -0
- package/dist/types/author.d.ts +1511 -0
- package/dist/types/author.js +9 -0
- package/dist/types/author.js.map +1 -0
- package/dist/types/index.js +30 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/section.d.ts +80 -0
- package/dist/types/section.js +3 -0
- package/dist/types/section.js.map +1 -0
- package/dist/types/story.d.ts +1865 -0
- package/dist/types/story.js +9 -0
- package/dist/types/story.js.map +1 -0
- package/dist/utils/cache.d.ts +21 -0
- package/dist/utils/cache.js +63 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/decorator.d.ts +2 -0
- package/dist/utils/decorator.js +21 -0
- package/dist/utils/decorator.js.map +1 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +21 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +52 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +7 -2
- package/.eslintrc.js +0 -26
- package/.github/workflows/build-test-lint.yml +0 -41
- package/.prettierrc +0 -7
- package/src/api/abstract-api.ts +0 -42
- package/src/api/author/index.ts +0 -13
- package/src/api/draft/index.ts +0 -12
- package/src/api/error.ts +0 -30
- package/src/api/identity/index.ts +0 -14
- package/src/api/identity/types.ts +0 -61
- package/src/api/ifx/index.ts +0 -64
- package/src/api/ifx/types.ts +0 -27
- package/src/api/index.ts +0 -37
- package/src/api/migration-center/index.ts +0 -47
- package/src/api/migration-center/types.ts +0 -173
- package/src/api/sales/index.ts +0 -22
- package/src/api/sales/types.ts +0 -73
- package/src/api/site/index.ts +0 -20
- package/src/api/websked/index.ts +0 -13
- package/src/api/websked/types.ts +0 -7
- package/src/api/ws.client.ts +0 -73
- package/src/content-elements/index.ts +0 -113
- package/src/tests/api/basic.test.ts +0 -15
- package/src/types/author.ts +0 -1537
- package/src/types/section.ts +0 -55
- package/src/types/story.ts +0 -1905
- package/src/utils/cache.ts +0 -63
- package/src/utils/decorator.ts +0 -20
- package/src/utils/duration.ts +0 -17
- package/src/utils/index.ts +0 -51
- package/tsconfig.json +0 -72
- package/vite.config.ts +0 -10
- /package/{src/api/author/types.ts → dist/api/author/types.d.ts} +0 -0
- /package/{src/api/draft/types.ts → dist/api/draft/types.d.ts} +0 -0
- /package/{src/api/site/types.ts → dist/api/site/types.d.ts} +0 -0
- /package/{src/types/index.ts → dist/types/index.d.ts} +0 -0
package/src/utils/cache.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Duration } from './duration';
|
|
2
|
-
|
|
3
|
-
export type CacheItem<Data> = { data: Data; ttl: number; timer?: NodeJS.Timer };
|
|
4
|
-
|
|
5
|
-
export default class Cache<Data = any> {
|
|
6
|
-
public constructor(private ttl = Duration.minutes(1), private maxSize = 1000) {}
|
|
7
|
-
|
|
8
|
-
private cache: Record<string, CacheItem<Data>> = {};
|
|
9
|
-
|
|
10
|
-
public get size() {
|
|
11
|
-
return this.keys.length;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public get keys() {
|
|
15
|
-
return Object.keys(this.cache);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public get values() {
|
|
19
|
-
return Object.values(this.cache).map(({ data }) => data);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public get(key: string): Data | void {
|
|
23
|
-
this.resetTimeout(key);
|
|
24
|
-
return this.cache[key]?.data;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public set(key: string, data: Data, ttl = this.ttl) {
|
|
28
|
-
this.pop();
|
|
29
|
-
this.del(key);
|
|
30
|
-
|
|
31
|
-
const item: CacheItem<Data> = { data, ttl };
|
|
32
|
-
this.cache[key] = item as Required<typeof item>;
|
|
33
|
-
this.toPop.push(key);
|
|
34
|
-
this.resetTimeout(key, ttl);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public del(key: string) {
|
|
38
|
-
if (!this.cache[key]) return;
|
|
39
|
-
const { timer } = this.cache[key];
|
|
40
|
-
if (timer) clearTimeout(timer);
|
|
41
|
-
delete this.cache[key];
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private resetTimeout(key: string, ttl?: number) {
|
|
46
|
-
const item = this.cache[key];
|
|
47
|
-
if (!item) return;
|
|
48
|
-
if (item.timer) clearTimeout(item.timer);
|
|
49
|
-
ttl = ttl ?? item.ttl;
|
|
50
|
-
if (Number.isFinite(ttl)) {
|
|
51
|
-
item.timer = setTimeout(() => {
|
|
52
|
-
this.del(key);
|
|
53
|
-
}, ttl);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private toPop: string[] = [];
|
|
58
|
-
private pop() {
|
|
59
|
-
if (this.toPop.length < this.maxSize) return;
|
|
60
|
-
const key = this.toPop.shift()!;
|
|
61
|
-
if (!this.del(key)) this.pop();
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/utils/decorator.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Cache from './cache';
|
|
2
|
-
|
|
3
|
-
export function Cached(cache: Cache) {
|
|
4
|
-
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void => {
|
|
5
|
-
const original = descriptor.value;
|
|
6
|
-
|
|
7
|
-
descriptor.value = async function value(...args: any[]) {
|
|
8
|
-
const key = JSON.stringify(args);
|
|
9
|
-
const cached = cache.get(key);
|
|
10
|
-
if (cached) {
|
|
11
|
-
return cached;
|
|
12
|
-
}
|
|
13
|
-
const data = await original.apply(this, args);
|
|
14
|
-
cache.set(key, data);
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(descriptor.value, 'name', { get: () => propertyKey });
|
|
19
|
-
};
|
|
20
|
-
}
|
package/src/utils/duration.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const Duration = {
|
|
2
|
-
seconds(s = 1) {
|
|
3
|
-
return s * 1000;
|
|
4
|
-
},
|
|
5
|
-
minutes(m = 1) {
|
|
6
|
-
return this.seconds(60) * m;
|
|
7
|
-
},
|
|
8
|
-
hours(h = 1) {
|
|
9
|
-
return this.minutes(60) * h;
|
|
10
|
-
},
|
|
11
|
-
days(d = 1) {
|
|
12
|
-
return this.hours(24) * d;
|
|
13
|
-
},
|
|
14
|
-
weeks(w = 1) {
|
|
15
|
-
return this.days(7) * w;
|
|
16
|
-
},
|
|
17
|
-
};
|
package/src/utils/index.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export const safeJSONParse = (data: string): any => {
|
|
2
|
-
try {
|
|
3
|
-
return JSON.parse(data);
|
|
4
|
-
} catch {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const safeJSONStringify = (data: any): string => {
|
|
10
|
-
try {
|
|
11
|
-
return JSON.stringify(data) || '';
|
|
12
|
-
} catch {
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const withTimeout = <T>(fn: Promise<T>, timeout: number): Promise<T> => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const nodeTimeout = setTimeout(() => {
|
|
20
|
-
reject(`Timeout ${timeout} exceed`);
|
|
21
|
-
}, timeout);
|
|
22
|
-
|
|
23
|
-
fn.then(
|
|
24
|
-
(data) => {
|
|
25
|
-
clearTimeout(nodeTimeout);
|
|
26
|
-
resolve(data);
|
|
27
|
-
},
|
|
28
|
-
(error) => {
|
|
29
|
-
clearTimeout(nodeTimeout);
|
|
30
|
-
reject(error);
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const AxiosResponseErrorInterceptor = <T = any, E extends Error = any>(
|
|
37
|
-
errorConstructor: (e: any) => E
|
|
38
|
-
): [onFulfilled?: (value: T) => T | Promise<T>, onRejected?: (error: any) => any] => {
|
|
39
|
-
return [
|
|
40
|
-
(response) => response,
|
|
41
|
-
(error) => {
|
|
42
|
-
throw errorConstructor(error);
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
48
|
-
|
|
49
|
-
export const timestampFromNow = (ms = 0) => {
|
|
50
|
-
return Date.now() + ms;
|
|
51
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
|
4
|
-
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"lib": ["ESNext"] /* Specify library files to be included in the compilation. */,
|
|
7
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
8
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
9
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
10
|
-
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
|
11
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
12
|
-
"sourceMap": true /* Generates corresponding '.map' file. */,
|
|
13
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
14
|
-
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
17
|
-
// "composite": true, /* Enable project compilation */
|
|
18
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
19
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
20
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
21
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
|
-
"downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
|
|
23
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
|
-
|
|
25
|
-
/* Strict Type-Checking Options */
|
|
26
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
27
|
-
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
|
28
|
-
"strictNullChecks": true /* Enable strict null checks. */,
|
|
29
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
30
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
31
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
32
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
33
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
34
|
-
|
|
35
|
-
/* Additional Checks */
|
|
36
|
-
"noUnusedLocals": false /* Report errors on unused locals. */,
|
|
37
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
38
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
39
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
40
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
41
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
|
42
|
-
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
43
|
-
|
|
44
|
-
/* Module Resolution Options */
|
|
45
|
-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
46
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
47
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
48
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
49
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
50
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
51
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
52
|
-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
53
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
54
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
55
|
-
|
|
56
|
-
/* Source Map Options */
|
|
57
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
58
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
59
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
60
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
61
|
-
|
|
62
|
-
/* Experimental Options */
|
|
63
|
-
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
|
|
64
|
-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
65
|
-
|
|
66
|
-
/* Advanced Options */
|
|
67
|
-
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
|
68
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
69
|
-
},
|
|
70
|
-
"include": ["src/**/*.ts"],
|
|
71
|
-
"exclude": ["./node_modules", "dist", "./vite.config.ts"]
|
|
72
|
-
}
|
package/vite.config.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|