@requence/service 0.7.1

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +330 -0
  3. package/build/chunk-6w7td62p.js +56 -0
  4. package/build/chunk-6w7td62p.js.map +10 -0
  5. package/build/cli.js +166 -0
  6. package/build/cli.js.map +10 -0
  7. package/build/index.js +1229 -0
  8. package/build/index.js.map +24 -0
  9. package/build/types/helpers/src/files/RequenceFile.d.ts +40 -0
  10. package/build/types/helpers/src/files/RequenceFile.d.ts.map +1 -0
  11. package/build/types/helpers/src/files/RequenceStream.d.ts +32 -0
  12. package/build/types/helpers/src/files/RequenceStream.d.ts.map +1 -0
  13. package/build/types/helpers/src/files/fileObject.d.ts +16 -0
  14. package/build/types/helpers/src/files/fileObject.d.ts.map +1 -0
  15. package/build/types/helpers/src/files/index.d.ts +7 -0
  16. package/build/types/helpers/src/files/index.d.ts.map +1 -0
  17. package/build/types/helpers/src/files/isValidMimeType.d.ts +5 -0
  18. package/build/types/helpers/src/files/isValidMimeType.d.ts.map +1 -0
  19. package/build/types/helpers/src/files/mapOutput.d.ts +10 -0
  20. package/build/types/helpers/src/files/mapOutput.d.ts.map +1 -0
  21. package/build/types/helpers/src/files/streamObject.d.ts +14 -0
  22. package/build/types/helpers/src/files/streamObject.d.ts.map +1 -0
  23. package/build/types/helpers/src/files/types.d.ts +4 -0
  24. package/build/types/helpers/src/files/types.d.ts.map +1 -0
  25. package/build/types/helpers/src/index.d.ts +13 -0
  26. package/build/types/helpers/src/index.d.ts.map +1 -0
  27. package/build/types/helpers/src/jsonschema/mapSchema.d.ts +20 -0
  28. package/build/types/helpers/src/jsonschema/mapSchema.d.ts.map +1 -0
  29. package/build/types/helpers/src/jsonschema/types.d.ts +13 -0
  30. package/build/types/helpers/src/jsonschema/types.d.ts.map +1 -0
  31. package/build/types/helpers/src/jsonschema/validate.d.ts +32 -0
  32. package/build/types/helpers/src/jsonschema/validate.d.ts.map +1 -0
  33. package/build/types/helpers/src/jsonschema/zod.d.ts +17 -0
  34. package/build/types/helpers/src/jsonschema/zod.d.ts.map +1 -0
  35. package/build/types/helpers/src/protocol/NodeTree.d.ts +510 -0
  36. package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -0
  37. package/build/types/helpers/src/protocol/command.d.ts +507 -0
  38. package/build/types/helpers/src/protocol/command.d.ts.map +1 -0
  39. package/build/types/helpers/src/protocol/helpers.d.ts +7 -0
  40. package/build/types/helpers/src/protocol/helpers.d.ts.map +1 -0
  41. package/build/types/helpers/src/protocol/index.d.ts +8 -0
  42. package/build/types/helpers/src/protocol/index.d.ts.map +1 -0
  43. package/build/types/helpers/src/protocol/nodeType.d.ts +187 -0
  44. package/build/types/helpers/src/protocol/nodeType.d.ts.map +1 -0
  45. package/build/types/helpers/src/protocol/taskOptions.d.ts +23 -0
  46. package/build/types/helpers/src/protocol/taskOptions.d.ts.map +1 -0
  47. package/build/types/helpers/src/protocol/templateNodeTypes.d.ts +267 -0
  48. package/build/types/helpers/src/protocol/templateNodeTypes.d.ts.map +1 -0
  49. package/build/types/helpers/src/protocol/treeNodes.d.ts +874 -0
  50. package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -0
  51. package/build/types/helpers/src/protocol/update.d.ts +406 -0
  52. package/build/types/helpers/src/protocol/update.d.ts.map +1 -0
  53. package/build/types/helpers/src/utils/callbackToAsyncIterator.d.ts +3 -0
  54. package/build/types/helpers/src/utils/callbackToAsyncIterator.d.ts.map +1 -0
  55. package/build/types/helpers/src/utils/clone.d.ts +3 -0
  56. package/build/types/helpers/src/utils/clone.d.ts.map +1 -0
  57. package/build/types/helpers/src/utils/createObjectProxy.d.ts +2 -0
  58. package/build/types/helpers/src/utils/createObjectProxy.d.ts.map +1 -0
  59. package/build/types/helpers/src/utils/debounce.d.ts +4 -0
  60. package/build/types/helpers/src/utils/debounce.d.ts.map +1 -0
  61. package/build/types/helpers/src/utils/guards.d.ts +3 -0
  62. package/build/types/helpers/src/utils/guards.d.ts.map +1 -0
  63. package/build/types/helpers/src/utils/mapData.d.ts +18 -0
  64. package/build/types/helpers/src/utils/mapData.d.ts.map +1 -0
  65. package/build/types/helpers/src/utils/matchSchema.d.ts +4 -0
  66. package/build/types/helpers/src/utils/matchSchema.d.ts.map +1 -0
  67. package/build/types/helpers/src/utils/obfuscate.d.ts +4 -0
  68. package/build/types/helpers/src/utils/obfuscate.d.ts.map +1 -0
  69. package/build/types/helpers/src/utils/obj.d.ts +4 -0
  70. package/build/types/helpers/src/utils/obj.d.ts.map +1 -0
  71. package/build/types/helpers/src/utils/requenceCallback.d.ts +17 -0
  72. package/build/types/helpers/src/utils/requenceCallback.d.ts.map +1 -0
  73. package/build/types/helpers/src/utils/resolveRequenceTypes.d.ts +8 -0
  74. package/build/types/helpers/src/utils/resolveRequenceTypes.d.ts.map +1 -0
  75. package/build/types/helpers/src/utils/types.d.ts +7 -0
  76. package/build/types/helpers/src/utils/types.d.ts.map +1 -0
  77. package/build/types/service/src/createAmqpConnection.d.ts +44 -0
  78. package/build/types/service/src/createAmqpConnection.d.ts.map +1 -0
  79. package/build/types/service/src/errors.d.ts +3 -0
  80. package/build/types/service/src/errors.d.ts.map +1 -0
  81. package/build/types/service/src/helpers.d.ts +98 -0
  82. package/build/types/service/src/helpers.d.ts.map +1 -0
  83. package/build/types/service/src/index.d.ts +20 -0
  84. package/build/types/service/src/index.d.ts.map +1 -0
  85. package/build/types/service/src/macro.d.ts +2 -0
  86. package/build/types/service/src/macro.d.ts.map +1 -0
  87. package/build/types/service/src/mapInput.d.ts +2 -0
  88. package/build/types/service/src/mapInput.d.ts.map +1 -0
  89. package/build/types/service/src/utils.d.ts +6 -0
  90. package/build/types/service/src/utils.d.ts.map +1 -0
  91. package/package.json +38 -0
@@ -0,0 +1,98 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import type { TaskOptions } from '../../helpers/src/protocol/index.js';
3
+ export type JSONValue = string | number | boolean | {
4
+ [x: string]: JSONValue;
5
+ } | Array<JSONValue> | null | undefined;
6
+ export declare class RetryError extends Error {
7
+ delay?: number | undefined;
8
+ constructor(delay?: number | undefined);
9
+ }
10
+ export declare class SkipError extends Error {
11
+ }
12
+ export declare class AbortError extends Error {
13
+ }
14
+ declare const OUTPUT_VALUE: unique symbol;
15
+ type OutputValue = {
16
+ [OUTPUT_VALUE]: string | null;
17
+ value: any;
18
+ };
19
+ export declare function processData(params: {
20
+ data: unknown;
21
+ outputName: null | string;
22
+ options: Pick<TaskOptions, 'uploadUrl' | 'streamUrl'>;
23
+ onCallback: (callback: (...args: any[]) => void) => {
24
+ callbackId: string;
25
+ sourceId: string;
26
+ };
27
+ onDone: () => void;
28
+ }): Promise<unknown>;
29
+ export declare function unwrapResult(params: {
30
+ result: unknown;
31
+ options: Pick<TaskOptions, 'uploadUrl' | 'streamUrl'>;
32
+ onCallback: (callback: (...args: any[]) => void) => {
33
+ callbackId: string;
34
+ sourceId: string;
35
+ };
36
+ onDone: () => void;
37
+ }): Promise<{
38
+ value: unknown;
39
+ outputName: string | null;
40
+ }>;
41
+ export default function createContextHelper(options: {
42
+ taskId: string;
43
+ input: unknown;
44
+ configuration: unknown;
45
+ onLog: (method: 'log' | 'warn' | 'info' | 'error', data: any[]) => void;
46
+ onDefer: (reason?: string) => string;
47
+ onCallback: (params: {
48
+ sourceId: string;
49
+ callbackId: string;
50
+ outputName: string | null;
51
+ propertyPath: (string | number)[];
52
+ arg: unknown;
53
+ }) => void;
54
+ }): readonly [{
55
+ readonly taskId: string;
56
+ readonly input: any;
57
+ readonly configuration: any;
58
+ readonly toOutput: (name: string | null, value: unknown) => OutputValue;
59
+ readonly defer: (reason?: string) => string;
60
+ readonly debug: {
61
+ readonly log: (...data: any[]) => void;
62
+ readonly info: (...data: any[]) => void;
63
+ readonly warn: (...data: any[]) => void;
64
+ readonly error: (...data: any[]) => void;
65
+ };
66
+ readonly retry: (delay?: number) => never;
67
+ readonly abort: (reason?: string) => never;
68
+ readonly skip: () => never;
69
+ readonly terminated: Promise<string> & {
70
+ signal: AbortSignal;
71
+ };
72
+ }, {
73
+ promise: Promise<string>;
74
+ resolve: (value?: string | PromiseLike<string> | undefined) => void;
75
+ reject: (reason?: any) => void;
76
+ }];
77
+ export type ContextHelper = ReturnType<typeof createContextHelper>[0];
78
+ export declare const handlerStorage: AsyncLocalStorage<{
79
+ readonly taskId: string;
80
+ readonly input: any;
81
+ readonly configuration: any;
82
+ readonly toOutput: (name: string | null, value: unknown) => OutputValue;
83
+ readonly defer: (reason?: string) => string;
84
+ readonly debug: {
85
+ readonly log: (...data: any[]) => void;
86
+ readonly info: (...data: any[]) => void;
87
+ readonly warn: (...data: any[]) => void;
88
+ readonly error: (...data: any[]) => void;
89
+ };
90
+ readonly retry: (delay?: number) => never;
91
+ readonly abort: (reason?: string) => never;
92
+ readonly skip: () => never;
93
+ readonly terminated: Promise<string> & {
94
+ signal: AbortSignal;
95
+ };
96
+ }>;
97
+ export {};
98
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC1B,KAAK,CAAC,SAAS,CAAC,GAChB,IAAI,GACJ,SAAS,CAAA;AAEb,qBAAa,UAAW,SAAQ,KAAK;IAChB,KAAK,CAAC,EAAE,MAAM;gBAAd,KAAK,CAAC,EAAE,MAAM,YAAA;CAGlC;AAED,qBAAa,SAAU,SAAQ,KAAK;CAAG;AAEvC,qBAAa,UAAW,SAAQ,KAAK;CAAG;AAExC,Q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AA;IACpC,UAAU,EAAE,CAAC,MAAM,EAAE;QACnB,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QACzB,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;QACjC,GAAG,EAAE,OAAO,CAAA;KACb,KAAK,IAAI,CAAA;CACX;;;;8BAiBoB,MAAM,GAAG,IAAI,SAAS,OAAO,KAAG,WAAW;8BAzB3C,MAAM,KAAK,MAAM;;gCAkCjB,GAAG,EAAE;iCAGJ,GAAG,EAAE;iCAGL,GAAG,EAAE;kCAGJ,GAAG,EAAE;;6BAIR,MAAM;8BAGL,MAAM;;;;;;;;mBAe6ywC,CAAC;GALx0wC;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA;AAErE,eAAO,MAAM,cAAc;;;;8BAvCN,MAAM,GAAG,IAAI,SAAS,OAAO,KAAG,WAAW;8BAzB3C,MAAM,KAAK,MAAM;;gCAkCjB,GAAG,EAAE;iCAGJ,GAAG,EAAE;iCAGL,GAAG,EAAE;kCAGJ,GAAG,EAAE;;6BAIR,MAAM;8BAGL,MAAM;;;;;EAcyC,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { AmqpConnectionManagerOptions } from 'amqp-connection-manager';
2
+ import { type ConnectionApi, type MessageHandler } from './createAmqpConnection.ts';
3
+ export { RequenceFile, RequenceStream } from '../../helpers/src/files/index.js';
4
+ export { createCallback, type RequenceCallback, type WrappedRequenceCallback, } from '../../helpers/src/index.js';
5
+ export * from './errors.ts';
6
+ export * from './utils.ts';
7
+ export { MessageHandler } from './createAmqpConnection.ts';
8
+ export type ServiceApi<V extends keyof RequenceService.Version | (string & {})> = ConnectionApi<V>;
9
+ interface ServiceOptions<V extends string> {
10
+ accessToken?: string;
11
+ devToken?: string;
12
+ version: V;
13
+ prefetch?: number;
14
+ connectionTimeout?: number;
15
+ silent?: boolean;
16
+ connectionOptions?: AmqpConnectionManagerOptions['connectionOptions'];
17
+ }
18
+ export declare function createService<V extends keyof RequenceService.Version | (string & {})>(version: V, messageHandler: MessageHandler<V>): ServiceApi<V>;
19
+ export declare function createService<V extends keyof RequenceService.Version | (string & {})>(options: ServiceOptions<V>, messageHandler: MessageHandler<V>): ServiceApi<V>;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AAE3E,OAA6B,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EACL,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,MAAM,MAAM,UAAU,CACpB,CAAC,SAAS,MAAM,eAAe,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,IACrD,aAAa,CAAC,CAAC,CAAC,CAAA;AAEpB,UAAU,cAAc,CAAC,CAAC,SAAS,MAAM;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iBAAiB,CAAC,EAAE,4BAA4B,CAAC,mBAAmB,CAAC,CAAA;CACtE;AAUD,wBAAgB,aAAa,CAC3B,CAAC,SAAS,MAAM,eAAe,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACvD,OAAO,EAAE,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;AAC/D,wBAAgB,aAAa,CAC3B,CAAC,SAAS,MAAM,eAAe,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACvD,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function libVersion(): string;
2
+ //# sourceMappingURL=macro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macro.d.ts","sourceRoot":"","sources":["../../../../src/macro.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,WAEzB"}
@@ -0,0 +1,2 @@
1
+ export default function mapInput(data: unknown): unknown;
2
+ //# sourceMappingURL=mapInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapInput.d.ts","sourceRoot":"","sources":["../../../../src/mapInput.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAWvD"}
@@ -0,0 +1,6 @@
1
+ export declare function wrapIterable<T extends Iterable<any> | AsyncIterable<any>>(iterable: T): T;
2
+ export declare function asyncEventEmitter<T>(initial?: Array<T>): {
3
+ push: (value: T) => void;
4
+ [Symbol.asyncIterator](): AsyncIterator<T>;
5
+ };
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,EACvE,QAAQ,EAAE,CAAC,GACV,CAAC,CAmDH;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAE,KAAK,CAAC,CAAC,CAAM;kBAWzC,CAAC;8BAOW,aAAa,CAAC,CAAC,CAAC;EAyB7C"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@requence/service",
3
+ "type": "module",
4
+ "version": "0.7.1",
5
+ "bin": {
6
+ "requence-service": "build/cli.js"
7
+ },
8
+ "scripts": {
9
+ "check-format": "oxfmt --check",
10
+ "fix-format": "oxfmt --write",
11
+ "check-types": "tsc",
12
+ "lint": "oxlint --deny-warnings",
13
+ "build-declaration": "tsc -p tsconfig.declaration.json && tsc-alias -p tsconfig.declaration.json 2>/dev/null",
14
+ "build": "ADD_ENTRYPOINT=src/cli.ts bun -e \"import('@requence/utils/build-package.mts')\" && bun build-declaration"
15
+ },
16
+ "dependencies": {
17
+ "ajv": "^8.17.1",
18
+ "amqp-connection-manager": "^4.1.14",
19
+ "amqplib": "^0.10.8",
20
+ "chalk": "^5.6.2",
21
+ "eventsource-client": "^1.2.0",
22
+ "mime-types": "^3.0.1",
23
+ "yargs": "^17.7.2",
24
+ "zod": "^4.3.6"
25
+ },
26
+ "devDependencies": {
27
+ "@requence/helpers": "workspace:*",
28
+ "@requence/utils": "workspace:*",
29
+ "@types/amqplib": "^0.10.7",
30
+ "@types/bun": "^1.2.23",
31
+ "@types/yargs": "^17.0.33",
32
+ "tsc-alias": "^1.8.16"
33
+ },
34
+ "exports": {
35
+ "default": "./build/index.js",
36
+ "types": "./build/types/service/src/index.d.ts"
37
+ }
38
+ }