@requence/service 1.0.0-alpha.1 → 1.0.0-alpha.11

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 (29) hide show
  1. package/CHANGELOG.md +33 -11
  2. package/build/chunk-7zejeth1.js +176 -0
  3. package/build/chunk-7zejeth1.js.map +13 -0
  4. package/build/cli.js +35 -19
  5. package/build/cli.js.map +3 -3
  6. package/build/index.js +15474 -436
  7. package/build/index.js.map +92 -16
  8. package/build/types/helpers/src/createRemotePromise.d.ts +7 -0
  9. package/build/types/helpers/src/createRemotePromise.d.ts.map +1 -0
  10. package/build/types/helpers/src/index.d.ts +6 -6
  11. package/build/types/helpers/src/index.d.ts.map +1 -1
  12. package/build/types/helpers/src/utils.d.ts +14 -4
  13. package/build/types/helpers/src/utils.d.ts.map +1 -1
  14. package/build/types/service/src/{connections/createAmqpConnection.d.ts → createAmqpConnection.d.ts} +10 -10
  15. package/build/types/service/src/createAmqpConnection.d.ts.map +1 -0
  16. package/build/types/service/src/helpers.d.ts +64 -78
  17. package/build/types/service/src/helpers.d.ts.map +1 -1
  18. package/build/types/service/src/index.d.ts +6 -5
  19. package/build/types/service/src/index.d.ts.map +1 -1
  20. package/build/types/service/src/mapInput.d.ts +2 -0
  21. package/build/types/service/src/mapInput.d.ts.map +1 -0
  22. package/package.json +6 -6
  23. package/build/chunk-2exhyr7n.js +0 -234
  24. package/build/chunk-2exhyr7n.js.map +0 -14
  25. package/build/types/helpers/src/service.d.ts +0 -156
  26. package/build/types/helpers/src/service.d.ts.map +0 -1
  27. package/build/types/helpers/src/task.d.ts +0 -49
  28. package/build/types/helpers/src/task.d.ts.map +0 -1
  29. package/build/types/service/src/connections/createAmqpConnection.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ export default function createRemotePromise<T = void>(onAwait?: (resolve: (value: T) => void, reject: (error: any) => void) => void | Promise<void>): Promise<T> & {
2
+ resolve: (value: T | PromiseLike<T>) => void;
3
+ reject: (reason?: any) => void;
4
+ promise: Promise<T>;
5
+ };
6
+ export type RemotePromise<T> = ReturnType<typeof createRemotePromise<T>>;
7
+ //# sourceMappingURL=createRemotePromise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRemotePromise.d.ts","sourceRoot":"","sources":["../../../../../helpers/src/createRemotePromise.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,GAAG,IAAI,EAClD,OAAO,CAAC,EAAE,CACR,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,KACzB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;qBAEI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI;sBAC1B,GAAG,KAAK,IAAI;;EAgC3C;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA"}
@@ -1,7 +1,7 @@
1
- export * from './service.js';
2
- export * from './utils.js';
3
- export { taskSchema, type Task } from './task.js';
4
- export * from './obfuscate.js';
5
- export { default as clone } from './clone.js';
6
- export { default as createObjectProxy } from './createObjectProxy.js';
1
+ export * from './utils.ts';
2
+ export * from './obfuscate.ts';
3
+ export { default as clone } from './clone.ts';
4
+ export { default as createObjectProxy } from './createObjectProxy.ts';
5
+ export { default as createRemotePromise } from './createRemotePromise.ts';
6
+ export { type RemotePromise } from './createRemotePromise.ts';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../helpers/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAA;AACjD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../helpers/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,7 +1,17 @@
1
- import type { z } from 'zod';
2
- import type { Condition, Service, SingleService } from './service.js';
1
+ import { z } from 'zod';
3
2
  export declare function matchSchema<Schema extends z.ZodSchema>(schema: Schema, input: unknown): input is z.infer<Schema>;
4
3
  export declare function matchSchema<Schema extends z.ZodSchema>(schema: Schema): (input: unknown) => input is z.infer<Schema>;
5
- export declare function flatServices(service: Service, excludeFallbacked?: boolean): (SingleService | Condition)[];
6
- export declare function extractServiceIds(service: Service, excludeFallbacked?: boolean): string[];
4
+ export declare function isRecord(data: unknown): data is Record<string, unknown>;
5
+ type DataVistor<T> = (data: T, path: Array<string | number>) => Promise<any> | any;
6
+ interface DataVistors {
7
+ Null?: DataVistor<null>;
8
+ String?: DataVistor<string>;
9
+ Number?: DataVistor<number>;
10
+ Object?: DataVistor<object>;
11
+ Array?: DataVistor<Array<any>>;
12
+ Buffer?: DataVistor<Buffer>;
13
+ }
14
+ type HasPromiseVistor<T extends DataVistors, Then, Else> = T[keyof T] extends (...args: any[]) => any ? Promise<any> extends ReturnType<T[keyof T]> ? Then : Else : Else;
15
+ export declare function mapData<Output, Input = unknown, V extends DataVistors = DataVistors>(data: Input, visitors: V): HasPromiseVistor<V, Promise<unknown extends Output ? Input : Output>, unknown extends Output ? Input : Output>;
16
+ export {};
7
17
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../helpers/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAErE,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC3B,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,GACb,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAa/C,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,UAAQ,iCAoCvE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,UAAQ,YAE5E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../helpers/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC3B,wBAAgB,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,MAAM,GACb,CAAC,KAAK,EAAE,OAAO,KAAK,KAA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AAG,KAAK,GAAG,MAAM,CACxC,CAyDA"}
@@ -1,12 +1,11 @@
1
- import { type ExtendendContextHelper, type JSONValue } from '../helpers.js';
1
+ import { type ContextHelper, type JSONValue } from './helpers.ts';
2
2
  type Input<V extends keyof Requence.Version> = Requence.Version[V]['input'];
3
3
  type Configuration<V extends keyof Requence.Version> = Requence.Version[V]['configuration'];
4
4
  type OutputName<V extends keyof Requence.Version, K = keyof Requence.Version[V]['outputs']> = K extends '__default__' ? null : K;
5
5
  type OutputValue<V extends keyof Requence.Version, O extends OutputName<V> | null> = Requence.Version[V]['outputs'][O extends null ? '__default__' : O];
6
- interface ServiceContextHelper<V extends keyof Requence.Version> extends Omit<ExtendendContextHelper, 'getData' | 'getConfiguration' | 'toOutput'> {
6
+ interface ServiceContextHelper<V extends keyof Requence.Version> extends Omit<ContextHelper, 'getData' | 'getConfiguration' | 'toOutput'> {
7
7
  getData: {
8
8
  (): Input<V>;
9
- (alias?: string): unknown;
10
9
  };
11
10
  getConfiguration(): Configuration<V>;
12
11
  toOutput<O extends OutputName<V>>(name: O, value: OutputValue<V, O>): '__output_value__';
@@ -14,13 +13,15 @@ interface ServiceContextHelper<V extends keyof Requence.Version> extends Omit<Ex
14
13
  type ReturnValue<V extends keyof Requence.Version> = ReturnType<ServiceContextHelper<V>['toOutput']> | OutputValue<V, null> | '__output_value__';
15
14
  type ApiOutputName<V> = V extends keyof Requence.Version ? OutputName<V> : string | null;
16
15
  type ApiOutputValue<V, O> = V extends keyof Requence.Version ? O extends OutputName<V> ? OutputValue<V, O> : unknown : unknown;
17
- interface ConnectionApi<V> {
16
+ interface ActorApi<V> {
17
+ sendToOutput<O extends ApiOutputName<V>>(outputName: O, data: ApiOutputValue<V, O>): void;
18
+ send(data: ApiOutputValue<V, null>): void;
19
+ abort(error: string | Error): void;
20
+ }
21
+ export interface ConnectionApi<V> {
18
22
  close(): Promise<void>;
19
23
  open(): Promise<ConnectionApi<V>>;
20
- sendToOutput<O extends ApiOutputName<V>>(messageKey: string, outputName: O, data: ApiOutputValue<V, O>): void;
21
- send(messageKey: string, data: ApiOutputValue<V, null>): void;
22
- end(messageKey: string): void;
23
- abort(messageKey: string, error: string | Error): void;
24
+ act(messageKey: string, actor: (api: ActorApi<V>) => void | Promise<void>): Promise<void>;
24
25
  }
25
26
  type MaybePromise<T> = T | Promise<T>;
26
27
  interface ConnectionOptions {
@@ -30,13 +31,12 @@ interface ConnectionOptions {
30
31
  prefetch?: number;
31
32
  silent?: boolean;
32
33
  }
33
- type MessageHandlerContext<V> = V extends keyof Requence.Version ? ServiceContextHelper<V> : ExtendendContextHelper;
34
+ type MessageHandlerContext<V> = V extends keyof Requence.Version ? ServiceContextHelper<V> : ContextHelper;
34
35
  type MessageHandlerReturnValue<V> = V extends keyof Requence.Version ? ReturnValue<V> : JSONValue;
35
36
  type MessageHandlerFunction<V> = (context: MessageHandlerContext<V>) => MaybePromise<MessageHandlerReturnValue<V> | void>;
36
37
  type MessageHandlerGenerator<V> = (context: MessageHandlerContext<V>) => Generator<MessageHandlerReturnValue<V>, MessageHandlerReturnValue<V>, void>;
37
38
  type MessageHandlerAsyncGenerator<V> = (context: MessageHandlerContext<V>) => AsyncGenerator<MessageHandlerReturnValue<V>, MessageHandlerReturnValue<V>, void>;
38
39
  export type MessageHandler<V> = MessageHandlerAsyncGenerator<V> | MessageHandlerGenerator<V> | MessageHandlerFunction<V>;
39
- export type Connection = ReturnType<typeof createConnection>;
40
40
  export default function createConnection<V>({ url, version, prefetch, silent, connectionTimeout, }: ConnectionOptions, messageHandler: MessageHandler<V>): ConnectionApi<V>;
41
41
  export {};
42
42
  //# sourceMappingURL=createAmqpConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAmqpConnection.d.ts","sourceRoot":"","sources":["../../../../src/createAmqpConnection.ts"],"names":[],"mappings":"AAOA,OAA4B,EAE1B,KAAK,aAAa,EAClB,KAAK,SAAS,EAGf,MAAM,cAAc,CAAA;AAGrB,KAAK,KAAK,CA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/helpers/context';
2
- import type { Nodes, ServiceNode } from '@requence/helpers/protocol';
1
+ import type { Context } from '@requence/helpers/context';
2
+ import type { NodeOptions, Nodes, ServiceNode } from '@requence/helpers/protocol';
3
3
  export type JSONValue = string | number | boolean | {
4
4
  [x: string]: JSONValue;
5
5
  } | Array<JSONValue> | null;
@@ -14,11 +14,16 @@ type OutputValue = {
14
14
  [OUTPUT_VALUE]: string | null;
15
15
  value: any;
16
16
  };
17
- export declare function unwrapResult(result: unknown): {
18
- value: any;
17
+ export declare function unwrapResult(result: unknown, options: NodeOptions): Promise<{
18
+ value: unknown;
19
19
  outputName: string | null;
20
+ }>;
21
+ type NodeResult = {
22
+ executionDate: null | Date;
23
+ data: any | null;
24
+ error: string | null;
20
25
  };
21
- export default function createExtendedContextHelper(options: {
26
+ export default function createContextHelper(options: {
22
27
  serviceId: string;
23
28
  taskId: string;
24
29
  context: Context;
@@ -28,83 +33,64 @@ export default function createExtendedContextHelper(options: {
28
33
  onDefer: (reason?: string) => string;
29
34
  onStateChange: (newObj: Record<string, unknown>) => void;
30
35
  }): {
31
- internal: {
32
- results: Map<string, {
33
- node: {
34
- id: "__entry__";
35
- type: "entry";
36
- output: import("@requence/helpers/protocol").Output[];
37
- meta?: Record<string, any> | undefined;
38
- inputSchema?: import("json-schema").JSONSchema7 | null | undefined;
39
- metaSchema?: import("json-schema").JSONSchema7 | null | undefined;
40
- } | {
41
- id: string;
42
- type: "service";
43
- name: string;
44
- version: string;
45
- output: import("@requence/helpers/protocol").Output[];
46
- alias?: string | undefined;
47
- configuration?: any;
48
- retry?: number | undefined;
49
- retryDelay?: number | undefined;
50
- meta?: Record<string, any> | undefined;
51
- inputSchema?: {
52
- type: "object";
53
- properties: Record<string, import("json-schema").JSONSchema7>;
54
- required?: string[] | undefined;
55
- description?: string | undefined;
56
- maxProperties?: number | undefined;
57
- minProperties?: number | undefined;
58
- additionalProperties?: boolean | undefined;
59
- } | null | undefined;
60
- ttl?: number | undefined;
61
- } | {
62
- id: string;
63
- type: "catch";
64
- output: import("@requence/helpers/protocol").Output[];
65
- subject: string;
66
- meta?: Record<string, any> | undefined;
67
- } | {
68
- id: string;
69
- type: "logic";
70
- output: import("@requence/helpers/protocol").Output[];
71
- script: string;
72
- concurrency: boolean;
73
- language: "javascript" | "python" | "typescript";
74
- maxExecutionTime: number;
75
- alias?: string | undefined;
76
- meta?: Record<string, any> | undefined;
77
- inputSchema?: {
78
- type: "object";
79
- properties: Record<string, import("json-schema").JSONSchema7>;
80
- required?: string[] | undefined;
81
- description?: string | undefined;
82
- maxProperties?: number | undefined;
83
- minProperties?: number | undefined;
84
- additionalProperties?: boolean | undefined;
85
- } | null | undefined;
86
- } | {
87
- id: string;
88
- type: "or";
89
- output: import("@requence/helpers/protocol").Output[];
90
- alias?: string | undefined;
91
- meta?: Record<string, any> | undefined;
92
- };
93
- executionDate: Date | null;
94
- data: any;
95
- error: string;
96
- }>;
97
- };
36
+ taskId: string;
98
37
  getInput(): unknown;
99
38
  getMeta(): unknown;
100
- getData(alias?: string): any;
101
- getError(alias: string): string | null;
102
- } & {
103
- taskId: string;
39
+ getData(): {
40
+ [x: string]: any;
41
+ };
104
42
  toOutput(name: string | null, value: unknown): OutputValue;
105
43
  defer: (reason?: string) => string;
106
44
  getConfiguration(): unknown;
107
- getNode(): ServiceNode;
45
+ getNode(): ServiceNode & NodeResult;
46
+ getNodes(): (({
47
+ type: "entry";
48
+ id: "__entry__";
49
+ output: import("@requence/helpers/protocol").Output[];
50
+ inputSchema: import("json-schema").JSONSchema7;
51
+ metaSchema: import("json-schema").JSONSchema7;
52
+ meta?: Record<string, any> | undefined;
53
+ } | {
54
+ type: "service";
55
+ id: string;
56
+ name: string;
57
+ output: import("@requence/helpers/protocol").Output[];
58
+ inputSchema: ({
59
+ type: "object";
60
+ } & import("json-schema").JSONSchema7) | {
61
+ type: "null";
62
+ };
63
+ version: string;
64
+ configurationSchema: import("json-schema").JSONSchema7;
65
+ meta?: Record<string, any> | undefined;
66
+ configuration?: any;
67
+ alias?: string | undefined;
68
+ ttl?: number | undefined;
69
+ retry?: number | undefined;
70
+ retryDelay?: number | undefined;
71
+ } | {
72
+ type: "catch";
73
+ id: string;
74
+ output: import("@requence/helpers/protocol").Output[];
75
+ subject: string;
76
+ meta?: Record<string, any> | undefined;
77
+ } | {
78
+ type: "logic";
79
+ id: string;
80
+ output: import("@requence/helpers/protocol").Output[];
81
+ script: string;
82
+ concurrency: boolean;
83
+ language: "javascript" | "python" | "typescript";
84
+ maxExecutionTime: number;
85
+ meta?: Record<string, any> | undefined;
86
+ alias?: string | undefined;
87
+ } | {
88
+ type: "or";
89
+ id: string;
90
+ output: import("@requence/helpers/protocol").Output[];
91
+ meta?: Record<string, any> | undefined;
92
+ alias?: string | undefined;
93
+ }) & NodeResult)[];
108
94
  state: Record<string, any>;
109
95
  debug: {
110
96
  log(...data: any[]): void;
@@ -115,6 +101,6 @@ export default function createExtendedContextHelper(options: {
115
101
  retry(delay?: number): never;
116
102
  abort(reason?: string): never;
117
103
  };
118
- export type ExtendendContextHelper = ReturnType<typeof createExtendedContextHelper>;
104
+ export type ContextHelper = ReturnType<typeof createContextHelper>;
119
105
  export {};
120
106
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,OAAO,EAGb,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAEpE,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,CAAA;AAER,qBAAa,UAAW,SAAQ,KAAK;IAChB,KAAK,CAAC,EAAE,MAAM;gBAAd,KAAK,CAAC,EAAE,MAAM,YAA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E,KAAK,IAAI,CAAA;IACvE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACpC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CACzD;;gBAkBe,OAAO;eAIR,OAAO;;;;mBAmBH,MAAM,GAAG,IAAI,SAAS,OAAO,GAAG,WAAW;qBA3CzC,MAAM,KAAK,MAAM;wBAmDd,OAAO;eAUe,WAAW,GAAG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAOA,MAAM,CACtE,MAAM,EACN,GAAG,CACJ;;qBAEc,GAAG,EAAE;sBAGJ,GAAG,EAAE;sBAGL,GAAG,EAAE;uBAGJ,GAAG,EAAE;;kBAIR,MAAM;mBAGL,MAAM;EAIxB;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -1,12 +1,13 @@
1
- import { type Connection, type MessageHandler } from './connections/createAmqpConnection.js';
1
+ import { type ConnectionApi, type MessageHandler } from './createAmqpConnection.ts';
2
+ export { RequenceFile, RequenceStream } from '@requence/helpers/files';
3
+ export type ServiceApi<V extends keyof Requence.Version | (string & {})> = ConnectionApi<V>;
2
4
  interface ServiceOptions<V extends string> {
3
- serviceKey?: string;
5
+ accessToken?: string;
4
6
  version: V;
5
7
  prefetch?: number;
6
8
  connectionTimeout?: number;
7
9
  silent?: boolean;
8
10
  }
9
- export default function createService<V extends keyof Requence.Version | (string & {})>(version: V, messageHandler: MessageHandler<V>): Connection;
10
- export default function createService<V extends keyof Requence.Version | (string & {})>(options: ServiceOptions<V>, messageHandler: MessageHandler<V>): Connection;
11
- export {};
11
+ export declare function createService<V extends keyof Requence.Version | (string & {})>(version: V, messageHandler: MessageHandler<V>): ServiceApi<V>;
12
+ export declare function createService<V extends keyof Requence.Version | (string & {})>(options: ServiceOptions<V>, messageHandler: MessageHandler<V>): ServiceApi<V>;
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAKA,OAA6B,EAC3B,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,uCAAuC,CAAA;AAS9C,UAAU,cAAc,CAAC,CAAC,SAAS,MAAM;IACvC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAkBD,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,CAAC,SAAS,MAAM,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAChD,OAAO,EAAE,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAA;AAC5D,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,CAAC,SAAS,MAAM,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAChD,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAKA,OAA6B,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEtE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,IACrE,aAAa,CAAC,CAAC,CAAC,CAAA;AAElB,UAAU,cAAc,CAAC,CAAC,SAAS,MAAM;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAkBD,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAC5E,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,CAAC,CAAC,CAAA;AAChB,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAC5E,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,CAAC,CAAC,CAAA"}
@@ -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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@requence/service",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.1",
4
+ "version": "1.0.0-alpha.11",
5
5
  "bin": {
6
6
  "requence-service": "build/cli.js"
7
7
  },
@@ -12,12 +12,12 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "amqp-connection-manager": "^4.1.14",
15
- "amqplib": "^0.10.4",
16
- "chalk": "^5.3.0",
17
- "prettier": "^3.3.3",
18
- "semver": "^7.6.3",
15
+ "amqplib": "^0.10.5",
16
+ "chalk": "^5.4.1",
17
+ "prettier": "^3.5.0",
18
+ "semver": "^7.7.1",
19
19
  "yargs": "^17.7.2",
20
- "zod": "^3.23.8"
20
+ "zod": "^3.24.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@requence/helpers": "workspace:*",
@@ -1,234 +0,0 @@
1
- // ../helpers/src/obfuscate.ts
2
- function obfuscate(...parts) {
3
- const str = parts.join(separator);
4
- let binaryString = "";
5
- for (let i = 0;i < str.length; i++) {
6
- const charCode = str.charCodeAt(i);
7
- binaryString += charCode.toString(2).padStart(16, "0");
8
- }
9
- let encodedString = "";
10
- const chunkSize = 6;
11
- let paddingCount = 0;
12
- for (let i = 0;i < binaryString.length; i += chunkSize) {
13
- let chunk = binaryString.substring(i, i + chunkSize);
14
- if (chunk.length < chunkSize) {
15
- paddingCount = chunkSize - chunk.length;
16
- chunk = chunk.padEnd(chunkSize, "0");
17
- }
18
- const decimalValue = parseInt(chunk, 2);
19
- encodedString += base65Chars[decimalValue];
20
- }
21
- return encodedString + paddingCount.toString();
22
- }
23
- function deobfuscate(str) {
24
- const paddingCount = parseInt(str.slice(-1), 10);
25
- str = str.slice(0, -1);
26
- let binaryString = "";
27
- for (let i = 0;i < str.length; i++) {
28
- const decimalValue = base65CharToIndex[str[i]];
29
- const binaryChunk = decimalValue.toString(2).padStart(6, "0");
30
- binaryString += binaryChunk;
31
- }
32
- if (paddingCount > 0) {
33
- binaryString = binaryString.slice(0, -paddingCount);
34
- }
35
- let decodedString = "";
36
- const charSize = 16;
37
- for (let i = 0;i < binaryString.length; i += charSize) {
38
- const byte = binaryString.substring(i, i + charSize);
39
- if (byte.length === 16) {
40
- const charCode = parseInt(byte, 2);
41
- decodedString += String.fromCharCode(charCode);
42
- }
43
- }
44
- return decodedString.split(separator);
45
- }
46
- var separator = "\uF6EE";
47
- var base65Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
48
- var base65CharToIndex = {};
49
- for (let i = 0;i < base65Chars.length; i++) {
50
- base65CharToIndex[base65Chars[i]] = i;
51
- }
52
-
53
- // ../helpers/src/service.ts
54
- import {z} from "zod";
55
- var uuidSchema = z.string().uuid();
56
- var serviceSchema = z.lazy(() => z.union([
57
- singleServiceSchema,
58
- sequenceServiceSchema,
59
- conditionSchema,
60
- parallelServiceSchema
61
- ]));
62
- var singleServiceSchema = z.object({
63
- id: uuidSchema,
64
- type: z.literal("service"),
65
- name: z.string(),
66
- version: z.string(),
67
- configuration: z.any().optional(),
68
- messageTTL: z.number().int().min(1).optional(),
69
- alias: z.string().optional(),
70
- retry: z.number().int().optional(),
71
- retryDelay: z.number().int().optional(),
72
- onFail: z.union([z.literal("skip"), serviceSchema.optional()])
73
- });
74
- var serviceListSchema = z.array(singleServiceSchema.pick({
75
- id: true,
76
- alias: true
77
- }).merge(singleServiceSchema.pick({
78
- name: true,
79
- version: true,
80
- configuration: true
81
- }).partial()));
82
- var parallelServiceSchema = z.object({
83
- type: z.literal("parallel"),
84
- name: z.string().optional(),
85
- services: z.array(serviceSchema).min(1)
86
- });
87
- var sequenceServiceSchema = z.object({
88
- type: z.literal("sequence"),
89
- name: z.string().optional(),
90
- services: z.array(serviceSchema).min(1)
91
- });
92
- var expressionSchema = z.union([
93
- z.object({
94
- property: z.union([z.boolean(), z.string(), z.number(), z.date()]),
95
- operator: z.enum(["==", "==="]),
96
- operant: z.union([z.boolean(), z.string(), z.number(), z.date()])
97
- }),
98
- z.object({
99
- property: z.union([z.number(), z.date(), z.string()]),
100
- operator: z.enum([">", "<", ">=", "<="]),
101
- operant: z.union([z.number(), z.date()])
102
- }),
103
- z.object({
104
- property: z.union([z.number(), z.date(), z.boolean(), z.string()]),
105
- operator: z.enum(["IN", "NOT_IN"]),
106
- operant: z.array(z.union([z.string(), z.number()]))
107
- }),
108
- z.object({
109
- property: z.string(),
110
- operator: z.literal("MATCHES"),
111
- operant: z.string()
112
- }),
113
- z.object({
114
- property: z.string(),
115
- operator: z.enum(["EXISTS", "NOT_EXISTS"])
116
- })
117
- ]);
118
- var conditionSchema = z.object({
119
- id: uuidSchema,
120
- type: z.literal("condition"),
121
- name: z.string().optional(),
122
- expression: expressionSchema,
123
- then: serviceSchema,
124
- else: serviceSchema.optional()
125
- });
126
- // ../helpers/src/task.ts
127
- import {z as z2} from "zod";
128
- function uniqueServices(task, ctx) {
129
- const serviceIds = new Set;
130
- const aliases = new Set;
131
- const addServiceId = (id) => {
132
- if (serviceIds.has(id)) {
133
- ctx.addIssue({
134
- code: z2.ZodIssueCode.custom,
135
- message: "serviceId is not unique",
136
- params: {
137
- id
138
- }
139
- });
140
- }
141
- serviceIds.add(id);
142
- };
143
- const addAlias = (alias) => {
144
- if (aliases.has(alias)) {
145
- ctx.addIssue({
146
- code: z2.ZodIssueCode.custom,
147
- message: "alias is not unique",
148
- params: {
149
- alias
150
- }
151
- });
152
- }
153
- aliases.add(alias);
154
- };
155
- const visitService = (service2) => {
156
- switch (service2.type) {
157
- case "service": {
158
- addServiceId(service2.id);
159
- if (service2.alias) {
160
- addAlias(service2.alias);
161
- }
162
- if (service2.onFail && service2.onFail !== "skip") {
163
- visitService(service2.onFail);
164
- }
165
- break;
166
- }
167
- case "parallel":
168
- case "sequence": {
169
- service2.services.forEach(visitService);
170
- break;
171
- }
172
- case "condition": {
173
- addServiceId(service2.id);
174
- visitService(service2.then);
175
- if (service2.else) {
176
- visitService(service2.else);
177
- }
178
- break;
179
- }
180
- }
181
- };
182
- visitService(task.pipeline);
183
- }
184
- var baseTaskSchema = z2.object({
185
- id: uuidSchema,
186
- input: z2.any(),
187
- meta: z2.any(),
188
- pipeline: serviceSchema
189
- });
190
- var taskSchema = baseTaskSchema.superRefine(uniqueServices);
191
- // ../helpers/src/clone.ts
192
- var CLONE_SYMBOL = Symbol("original");
193
- function clone(data) {
194
- if (typeof data !== "object" || data === null) {
195
- return data;
196
- }
197
- const target = data[CLONE_SYMBOL];
198
- if (target) {
199
- return clone(target);
200
- }
201
- if (Array.isArray(data)) {
202
- return data.map(clone);
203
- }
204
- return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, clone(value)]));
205
- }
206
- // ../helpers/src/createObjectProxy.ts
207
- function createObjectProxy(obj, onChange) {
208
- return new Proxy(obj, {
209
- set(target, property, newValue) {
210
- const result = Reflect.set(target, property, newValue);
211
- onChange(target);
212
- return result;
213
- },
214
- deleteProperty(target, property) {
215
- const result = Reflect.deleteProperty(target, property);
216
- onChange(target);
217
- return result;
218
- },
219
- get(target, property, receiver) {
220
- if (property === CLONE_SYMBOL) {
221
- return target;
222
- }
223
- const result = Reflect.get(target, property, receiver);
224
- if (typeof result === "object" && result !== null) {
225
- return createObjectProxy(result, () => onChange(target));
226
- }
227
- return result;
228
- }
229
- });
230
- }
231
- export { obfuscate, deobfuscate, clone, createObjectProxy };
232
-
233
- //# debugId=BEBA23696243BAE964756E2164756E21
234
- //# sourceMappingURL=chunk-2exhyr7n.js.map