@tonytang99/integration-phases 1.1.0 → 1.2.0

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 (101) hide show
  1. package/dist/extract/bigcommerce/extract-bc-customer.d.ts +28 -0
  2. package/dist/extract/bigcommerce/extract-bc-customer.d.ts.map +1 -0
  3. package/dist/extract/bigcommerce/extract-bc-customer.js +54 -0
  4. package/dist/extract/bigcommerce/extract-bc-customer.js.map +1 -0
  5. package/dist/extract/bigcommerce/extract-bc-order.d.ts +20 -0
  6. package/dist/extract/bigcommerce/extract-bc-order.d.ts.map +1 -0
  7. package/dist/extract/bigcommerce/extract-bc-order.js +47 -0
  8. package/dist/extract/bigcommerce/extract-bc-order.js.map +1 -0
  9. package/dist/extract/bigcommerce/extract-bc-transactions.d.ts +17 -0
  10. package/dist/extract/bigcommerce/extract-bc-transactions.d.ts.map +1 -0
  11. package/dist/extract/bigcommerce/extract-bc-transactions.js +36 -0
  12. package/dist/extract/bigcommerce/extract-bc-transactions.js.map +1 -0
  13. package/dist/extract/bigcommerce/index.d.ts +4 -0
  14. package/dist/extract/bigcommerce/index.d.ts.map +1 -0
  15. package/dist/extract/bigcommerce/index.js +15 -0
  16. package/dist/extract/bigcommerce/index.js.map +1 -0
  17. package/dist/extract/index.d.ts +3 -0
  18. package/dist/extract/index.d.ts.map +1 -0
  19. package/dist/extract/index.js +25 -0
  20. package/dist/extract/index.js.map +1 -0
  21. package/dist/index.d.ts +6 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +25 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/load/index.d.ts +2 -0
  26. package/dist/load/index.d.ts.map +1 -0
  27. package/dist/load/index.js +19 -0
  28. package/dist/load/index.js.map +1 -0
  29. package/dist/load/myob/index.d.ts +4 -0
  30. package/dist/load/myob/index.d.ts.map +1 -0
  31. package/dist/load/myob/index.js +14 -0
  32. package/dist/load/myob/index.js.map +1 -0
  33. package/dist/load/myob/load-myob-customer.d.ts +18 -0
  34. package/dist/load/myob/load-myob-customer.d.ts.map +1 -0
  35. package/dist/load/myob/load-myob-customer.js +53 -0
  36. package/dist/load/myob/load-myob-customer.js.map +1 -0
  37. package/dist/load/myob/load-myob-payment.d.ts +18 -0
  38. package/dist/load/myob/load-myob-payment.d.ts.map +1 -0
  39. package/dist/load/myob/load-myob-payment.js +47 -0
  40. package/dist/load/myob/load-myob-payment.js.map +1 -0
  41. package/dist/load/myob/load-myob-sales-order.d.ts +18 -0
  42. package/dist/load/myob/load-myob-sales-order.d.ts.map +1 -0
  43. package/dist/load/myob/load-myob-sales-order.js +53 -0
  44. package/dist/load/myob/load-myob-sales-order.js.map +1 -0
  45. package/dist/slots/bigcommerce-slots.d.ts +16 -0
  46. package/dist/slots/bigcommerce-slots.d.ts.map +1 -0
  47. package/dist/slots/bigcommerce-slots.js +29 -0
  48. package/dist/slots/bigcommerce-slots.js.map +1 -0
  49. package/dist/slots/index.d.ts +4 -0
  50. package/dist/slots/index.d.ts.map +1 -0
  51. package/dist/slots/index.js +11 -0
  52. package/dist/slots/index.js.map +1 -0
  53. package/dist/slots/myob-slots.d.ts +24 -0
  54. package/dist/slots/myob-slots.d.ts.map +1 -0
  55. package/dist/slots/myob-slots.js +41 -0
  56. package/dist/slots/myob-slots.js.map +1 -0
  57. package/dist/slots/processing-slots.d.ts +35 -0
  58. package/dist/slots/processing-slots.d.ts.map +1 -0
  59. package/dist/slots/processing-slots.js +39 -0
  60. package/dist/slots/processing-slots.js.map +1 -0
  61. package/dist/transform/index.d.ts +4 -0
  62. package/dist/transform/index.d.ts.map +1 -0
  63. package/dist/transform/index.js +14 -0
  64. package/dist/transform/index.js.map +1 -0
  65. package/dist/transform/transform-bc-customer.d.ts +25 -0
  66. package/dist/transform/transform-bc-customer.d.ts.map +1 -0
  67. package/dist/transform/transform-bc-customer.js +66 -0
  68. package/dist/transform/transform-bc-customer.js.map +1 -0
  69. package/dist/transform/transform-bc-order.d.ts +13 -0
  70. package/dist/transform/transform-bc-order.d.ts.map +1 -0
  71. package/dist/transform/transform-bc-order.js +30 -0
  72. package/dist/transform/transform-bc-order.js.map +1 -0
  73. package/dist/transform/transform-to-myob.d.ts +37 -0
  74. package/dist/transform/transform-to-myob.d.ts.map +1 -0
  75. package/dist/transform/transform-to-myob.js +79 -0
  76. package/dist/transform/transform-to-myob.js.map +1 -0
  77. package/dist/utility/index.d.ts +5 -0
  78. package/dist/utility/index.d.ts.map +1 -0
  79. package/dist/utility/index.js +12 -0
  80. package/dist/utility/index.js.map +1 -0
  81. package/dist/utility/parse-api-gateway-input.d.ts +27 -0
  82. package/dist/utility/parse-api-gateway-input.d.ts.map +1 -0
  83. package/dist/utility/parse-api-gateway-input.js +85 -0
  84. package/dist/utility/parse-api-gateway-input.js.map +1 -0
  85. package/dist/utility/wait-phase.d.ts +45 -0
  86. package/dist/utility/wait-phase.d.ts.map +1 -0
  87. package/dist/utility/wait-phase.js +76 -0
  88. package/dist/utility/wait-phase.js.map +1 -0
  89. package/dist/validate/check-customer-exists.d.ts +25 -0
  90. package/dist/validate/check-customer-exists.d.ts.map +1 -0
  91. package/dist/validate/check-customer-exists.js +67 -0
  92. package/dist/validate/check-customer-exists.js.map +1 -0
  93. package/dist/validate/index.d.ts +5 -0
  94. package/dist/validate/index.d.ts.map +1 -0
  95. package/dist/validate/index.js +11 -0
  96. package/dist/validate/index.js.map +1 -0
  97. package/dist/validate/verify-new-order.d.ts +27 -0
  98. package/dist/validate/verify-new-order.d.ts.map +1 -0
  99. package/dist/validate/verify-new-order.js +55 -0
  100. package/dist/validate/verify-new-order.js.map +1 -0
  101. package/package.json +4 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-to-myob.js","sourceRoot":"","sources":["../../src/transform/transform-to-myob.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAmF;AACnF,2EAI0C;AAC1C,kEAA8D;AAC9D,oDAAgD;AAEhD;;GAEG;AACH,MAAa,4BAA6B,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iB,EAAE,CAC3C,CAAC;QAEF,OAAO,GAAG,CAAC,GAAG,CAAC,sBAAS,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;CACF;AA5BD,wDA4BC"}
@@ -0,0 +1,5 @@
1
+ export { ParseAPIGatewayInputPhase, createParseAPIGatewayInputPhase, } from './parse-api-gateway-input';
2
+ export type { ParseAPIGatewayInputConfig } from './parse-api-gateway-input';
3
+ export { WaitPhase, createWaitPhase, createExponentialBackoffWaitPhase, } from './wait-phase';
4
+ export type { WaitConfig } from './wait-phase';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utility/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EACL,SAAS,EACT,eAAe,EACf,iCAAiC,GAClC,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // packages/phases/src/utility/index.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createExponentialBackoffWaitPhase = exports.createWaitPhase = exports.WaitPhase = exports.createParseAPIGatewayInputPhase = exports.ParseAPIGatewayInputPhase = void 0;
5
+ var parse_api_gateway_input_1 = require("./parse-api-gateway-input");
6
+ Object.defineProperty(exports, "ParseAPIGatewayInputPhase", { enumerable: true, get: function () { return parse_api_gateway_input_1.ParseAPIGatewayInputPhase; } });
7
+ Object.defineProperty(exports, "createParseAPIGatewayInputPhase", { enumerable: true, get: function () { return parse_api_gateway_input_1.createParseAPIGatewayInputPhase; } });
8
+ var wait_phase_1 = require("./wait-phase");
9
+ Object.defineProperty(exports, "WaitPhase", { enumerable: true, get: function () { return wait_phase_1.WaitPhase; } });
10
+ Object.defineProperty(exports, "createWaitPhase", { enumerable: true, get: function () { return wait_phase_1.createWaitPhase; } });
11
+ Object.defineProperty(exports, "createExponentialBackoffWaitPhase", { enumerable: true, get: function () { return wait_phase_1.createExponentialBackoffWaitPhase; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utility/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,qEAGmC;AAFjC,oIAAA,yBAAyB,OAAA;AACzB,0IAAA,+BAA+B,OAAA;AAIjC,2CAIsB;AAHpB,uGAAA,SAAS,OAAA;AACT,6GAAA,eAAe,OAAA;AACf,+HAAA,iCAAiC,OAAA"}
@@ -0,0 +1,27 @@
1
+ import { BasePhase, PipelineContext, SlotKey } from '@tonytang99/integration-core';
2
+ /**
3
+ * Configuration for API Gateway input parsing
4
+ */
5
+ export interface ParseAPIGatewayInputConfig {
6
+ /** Key in the body JSON that contains the order ID */
7
+ orderIdKey?: string;
8
+ /** Whether to expect the order ID in path parameters instead */
9
+ orderIdFromPath?: boolean;
10
+ /** Path parameter name for order ID */
11
+ pathParamName?: string;
12
+ }
13
+ /**
14
+ * Parses API Gateway event input and extracts order ID
15
+ */
16
+ export declare class ParseAPIGatewayInputPhase extends BasePhase {
17
+ private config;
18
+ readonly name = "utility:parse-api-gateway-input";
19
+ readonly description = "Parses API Gateway event and extracts order ID";
20
+ readonly tags: string[];
21
+ readonly requires: SlotKey<unknown>[];
22
+ readonly produces: SlotKey<unknown>[];
23
+ constructor(config?: ParseAPIGatewayInputConfig);
24
+ execute(ctx: PipelineContext): Promise<PipelineContext>;
25
+ }
26
+ export declare function createParseAPIGatewayInputPhase(config?: ParseAPIGatewayInputConfig): ParseAPIGatewayInputPhase;
27
+ //# sourceMappingURL=parse-api-gateway-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-api-gateway-input.d.ts","sourceRoot":"","sources":["../../src/utility/parse-api-gateway-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAInF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IAY1C,OAAO,CAAC,MAAM;IAX1B,QAAQ,CAAC,IAAI,qCAAqC;IAClD,QAAQ,CAAC,WAAW,oDAAoD;IACxE,QAAQ,CAAC,IAAI,WAAuC;IAEpD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAA+B;IACpE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAInC;gBAEkB,MAAM,GAAE,0BAA+B;IAIrD,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CA+D9D;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,CAAC,EAAE,0BAA0B,GAClC,yBAAyB,CAE3B"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParseAPIGatewayInputPhase = void 0;
4
+ exports.createParseAPIGatewayInputPhase = createParseAPIGatewayInputPhase;
5
+ // packages/phases/src/utility/parse-api-gateway-input.ts
6
+ const integration_core_1 = require("@tonytang99/integration-core");
7
+ const bigcommerce_slots_1 = require("../slots/bigcommerce-slots");
8
+ const processing_slots_1 = require("../slots/processing-slots");
9
+ /**
10
+ * Parses API Gateway event input and extracts order ID
11
+ */
12
+ class ParseAPIGatewayInputPhase extends integration_core_1.BasePhase {
13
+ config;
14
+ name = 'utility:parse-api-gateway-input';
15
+ description = 'Parses API Gateway event and extracts order ID';
16
+ tags = ['utility', 'input', 'api-gateway'];
17
+ requires = [processing_slots_1.ProcessingSlots.RAW_EVENT];
18
+ produces = [
19
+ bigcommerce_slots_1.BigCommerceSlots.ORDER_ID,
20
+ processing_slots_1.ProcessingSlots.RAW_WEBHOOK_PAYLOAD,
21
+ processing_slots_1.ProcessingSlots.SYNC_STARTED_AT,
22
+ ];
23
+ constructor(config = {}) {
24
+ super();
25
+ this.config = config;
26
+ }
27
+ async execute(ctx) {
28
+ const event = ctx.require(processing_slots_1.ProcessingSlots.RAW_EVENT);
29
+ const orderIdKey = this.config.orderIdKey ?? 'order_id';
30
+ let orderId;
31
+ let webhookPayload = undefined;
32
+ // Try to extract from path parameters first if configured
33
+ if (this.config.orderIdFromPath) {
34
+ const pathParamName = this.config.pathParamName ?? 'orderId';
35
+ const pathValue = event.pathParameters?.[pathParamName];
36
+ if (pathValue) {
37
+ orderId = parseInt(pathValue, 10);
38
+ }
39
+ }
40
+ // Parse body if present
41
+ if (event.body) {
42
+ try {
43
+ const body = JSON.parse(event.body);
44
+ webhookPayload = body;
45
+ // Extract order ID from body if not already found
46
+ if (!orderId && body[orderIdKey]) {
47
+ orderId = parseInt(body[orderIdKey], 10);
48
+ }
49
+ // Handle BigCommerce webhook format
50
+ if (!orderId && body.data?.id) {
51
+ orderId = body.data.id;
52
+ }
53
+ // Handle nested scope format
54
+ if (!orderId && body.scope) {
55
+ const match = body.scope.match(/orders\/(\d+)/);
56
+ if (match) {
57
+ orderId = parseInt(match[1], 10);
58
+ }
59
+ }
60
+ }
61
+ catch {
62
+ this.fail('INVALID_JSON', 'Failed to parse request body as JSON', false);
63
+ }
64
+ }
65
+ // Extract from query params as fallback
66
+ if (!orderId && event.queryStringParameters?.order_id) {
67
+ orderId = parseInt(event.queryStringParameters.order_id, 10);
68
+ }
69
+ if (!orderId || isNaN(orderId)) {
70
+ this.fail('MISSING_ORDER_ID', 'Could not extract order ID from event', false);
71
+ }
72
+ let result = ctx
73
+ .set(bigcommerce_slots_1.BigCommerceSlots.ORDER_ID, orderId)
74
+ .set(processing_slots_1.ProcessingSlots.SYNC_STARTED_AT, new Date());
75
+ if (webhookPayload) {
76
+ result = result.set(processing_slots_1.ProcessingSlots.RAW_WEBHOOK_PAYLOAD, webhookPayload);
77
+ }
78
+ return result;
79
+ }
80
+ }
81
+ exports.ParseAPIGatewayInputPhase = ParseAPIGatewayInputPhase;
82
+ function createParseAPIGatewayInputPhase(config) {
83
+ return new ParseAPIGatewayInputPhase(config);
84
+ }
85
+ //# sourceMappingURL=parse-api-gateway-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-api-gateway-input.js","sourceRoot":"","sources":["../../src/utility/parse-api-gateway-input.ts"],"names":[],"mappings":";;;AAqGA,0EAIC;AAzGD,yDAAyD;AACzD,mEAAmF;AACnF,kEAA8D;AAC9D,gEAA6E;AAc7E;;GAEG;AACH,MAAa,yBAA0B,SAAQ,4BAAS;IAYlC;IAXX,IAAI,GAAG,iCAAiC,CAAC;IACzC,WAAW,GAAG,gDAAgD,CAAC;IAC/D,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IAE3C,QAAQ,GAAuB,CAAC,kCAAe,CAAC,SAAS,CAAC,CAAC;IAC3D,QAAQ,GAAuB;QACtC,oCAAgB,CAAC,QAAQ;QACzB,kCAAe,CAAC,mBAAmB;QACnC,kCAAe,CAAC,eAAe;KAChC,CAAC;IAEF,YAAoB,SAAqC,EAAE;QACzD,KAAK,EAAE,CAAC;QADU,WAAM,GAAN,MAAM,CAAiC;IAE3D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAoB;QAChC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,kCAAe,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,UAAU,CAAC;QAExD,IAAI,OAA2B,CAAC;QAChC,IAAI,cAAc,GAAY,SAAS,C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KAAK,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,qBAAqB,EAAE,QAAQ,EAAE,CAAC;YACtD,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,MAAM,GAAG,GAAG;aACb,GAAG,CAAC,oCAAgB,CAAC,QAAQ,EAAE,OAAQ,CAAC;aACxC,GAAG,CAAC,kCAAe,CAAC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAEpD,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAe,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/ED,8DA+EC;AAED,SAAgB,+BAA+B,CAC7C,MAAmC;IAEnC,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { BasePhase, PipelineContext, SlotKey } from '@tonytang99/integration-core';
2
+ /**
3
+ * Wait configuration options
4
+ */
5
+ export interface WaitConfig {
6
+ /** Type of wait */
7
+ type: 'fixed' | 'exponential-backoff';
8
+ /** Duration in milliseconds for fixed wait */
9
+ durationMs?: number;
10
+ /** Initial delay for exponential backoff */
11
+ initialDelayMs?: number;
12
+ /** Maximum delay for exponential backoff */
13
+ maxDelayMs?: number;
14
+ /** Attempt number slot for exponential backoff */
15
+ attemptKey?: string;
16
+ }
17
+ /**
18
+ * Phase that introduces a wait/delay in the pipeline
19
+ * Useful for rate limiting or waiting for external system processing
20
+ */
21
+ export declare class WaitPhase extends BasePhase {
22
+ private config;
23
+ readonly name: string;
24
+ readonly description: string;
25
+ readonly tags: string[];
26
+ readonly requires: SlotKey<unknown>[];
27
+ readonly produces: SlotKey<unknown>[];
28
+ constructor(config: WaitConfig);
29
+ execute(ctx: PipelineContext): Promise<PipelineContext>;
30
+ private calculateDelay;
31
+ private sleep;
32
+ }
33
+ /**
34
+ * Creates a fixed-duration wait phase
35
+ */
36
+ export declare function createWaitPhase(durationMs: number): WaitPhase;
37
+ /**
38
+ * Creates an exponential backoff wait phase
39
+ */
40
+ export declare function createExponentialBackoffWaitPhase(config: {
41
+ initialDelayMs?: number;
42
+ maxDelayMs?: number;
43
+ attemptKey?: string;
44
+ }): WaitPhase;
45
+ //# sourceMappingURL=wait-phase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-phase.d.ts","sourceRoot":"","sources":["../../src/utility/wait-phase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAiB,MAAM,8BAA8B,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mBAAmB;IACnB,IAAI,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACtC,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAS;IAQ1B,OAAO,CAAC,MAAM;IAP1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,WAAiC;IAE9C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAM;IAC3C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAM;gBAEvB,MAAM,EAAE,UAAU;IAQhC,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAU7D,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,KAAK;CAGd;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAE7D;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,SAAS,CAKZ"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WaitPhase = void 0;
4
+ exports.createWaitPhase = createWaitPhase;
5
+ exports.createExponentialBackoffWaitPhase = createExponentialBackoffWaitPhase;
6
+ // packages/phases/src/utility/wait-phase.ts
7
+ const integration_core_1 = require("@tonytang99/integration-core");
8
+ /**
9
+ * Phase that introduces a wait/delay in the pipeline
10
+ * Useful for rate limiting or waiting for external system processing
11
+ */
12
+ class WaitPhase extends integration_core_1.BasePhase {
13
+ config;
14
+ name;
15
+ description;
16
+ tags = ['utility', 'wait', 'timing'];
17
+ requires = [];
18
+ produces = [];
19
+ constructor(config) {
20
+ super();
21
+ this.config = config;
22
+ this.name = `utility:wait:${config.type}`;
23
+ this.description = config.type === 'fixed'
24
+ ? `Waits for ${config.durationMs}ms`
25
+ : 'Waits with exponential backoff';
26
+ }
27
+ async execute(ctx) {
28
+ const delayMs = this.calculateDelay(ctx);
29
+ if (delayMs > 0) {
30
+ await this.sleep(delayMs);
31
+ }
32
+ return ctx;
33
+ }
34
+ calculateDelay(ctx) {
35
+ if (this.config.type === 'fixed') {
36
+ return this.config.durationMs ?? 1000;
37
+ }
38
+ // Exponential backoff
39
+ const initialDelay = this.config.initialDelayMs ?? 1000;
40
+ const maxDelay = this.config.maxDelayMs ?? 30000;
41
+ // Get attempt number from context if available
42
+ let attempt = 1;
43
+ if (this.config.attemptKey) {
44
+ const slotKey = (0, integration_core_1.createSlotKey)(this.config.attemptKey);
45
+ const value = ctx.get(slotKey);
46
+ if (value !== undefined) {
47
+ attempt = value;
48
+ }
49
+ }
50
+ // Calculate delay with jitter
51
+ const exponentialDelay = initialDelay * Math.pow(2, attempt - 1);
52
+ const jitter = Math.random() * 0.1 * exponentialDelay;
53
+ const delay = Math.min(exponentialDelay + jitter, maxDelay);
54
+ return Math.floor(delay);
55
+ }
56
+ sleep(ms) {
57
+ return new Promise(resolve => setTimeout(resolve, ms));
58
+ }
59
+ }
60
+ exports.WaitPhase = WaitPhase;
61
+ /**
62
+ * Creates a fixed-duration wait phase
63
+ */
64
+ function createWaitPhase(durationMs) {
65
+ return new WaitPhase({ type: 'fixed', durationMs });
66
+ }
67
+ /**
68
+ * Creates an exponential backoff wait phase
69
+ */
70
+ function createExponentialBackoffWaitPhase(config) {
71
+ return new WaitPhase({
72
+ type: 'exponential-backoff',
73
+ ...config,
74
+ });
75
+ }
76
+ //# sourceMappingURL=wait-phase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-phase.js","sourceRoot":"","sources":["../../src/utility/wait-phase.ts"],"names":[],"mappings":";;;AAoFA,0CAEC;AAKD,8EASC;AApGD,4CAA4C;AAC5C,mEAAkG;AAkBlG;;;GAGG;AACH,MAAa,SAAU,SAAQ,4BAAS;IAQlB;IAPX,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,IAAI,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAErC,QAAQ,GAAuB,EAAE,CAAC;IAClC,QAAQ,GAAuB,EAAE,CAAC;IAE3C,YAAoB,MAAkB;QACpC,KAAK,EAAE,CAAC;QADU,WAAM,GA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AAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,gBAAgB,CAAC;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAxDD,8BAwDC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,UAAkB;IAChD,OAAO,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,MAIjD;IACC,OAAO,IAAI,SAAS,CAAC;QACnB,IAAI,EAAE,qBAAqB;QAC3B,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { BasePhase, PipelineContext, SlotKey } from '@tonytang99/integration-core';
2
+ import { MYOBCustomerAdapter } from '@tonytang99/integration-adapters';
3
+ /**
4
+ * Configuration for customer existence check
5
+ */
6
+ export interface CheckCustomerExistsConfig {
7
+ /** Strategy for matching customers */
8
+ matchStrategy?: 'email' | 'name' | 'both';
9
+ }
10
+ /**
11
+ * Checks if a customer already exists in MYOB based on BC customer data
12
+ */
13
+ export declare class CheckCustomerExistsPhase extends BasePhase {
14
+ private adapter;
15
+ private config;
16
+ readonly name = "validate:check-customer-exists";
17
+ readonly description = "Checks if customer exists in MYOB";
18
+ readonly tags: string[];
19
+ readonly requires: SlotKey<unknown>[];
20
+ readonly produces: SlotKey<unknown>[];
21
+ constructor(adapter: MYOBCustomerAdapter, config?: CheckCustomerExistsConfig);
22
+ execute(ctx: PipelineContext): Promise<PipelineContext>;
23
+ }
24
+ export declare function createCheckCustomerExistsPhase(adapter: MYOBCustomerAdapter, config?: CheckCustomerExistsConfig): CheckCustomerExistsPhase;
25
+ //# sourceMappingURL=check-customer-exists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-customer-exists.d.ts","sourceRoot":"","sources":["../../src/validate/check-customer-exists.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,sCAAsC;IACtC,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;CAC3C;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IAenD,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IAfhB,QAAQ,CAAC,IAAI,oCAAoC;IACjD,QAAQ,CAAC,WAAW,uCAAuC;IAC3D,QAAQ,CAAC,IAAI,WAAoC;IAEjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAEnC;IACF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAInC;gBAGQ,OAAO,EAAE,mBAAmB,EAC5B,MAAM,GAAE,yBAA8B;IAK1C,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAwC9D;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,CAAC,EAAE,yBAAyB,GACjC,wBAAwB,CAE1B"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckCustomerExistsPhase = void 0;
4
+ exports.createCheckCustomerExistsPhase = createCheckCustomerExistsPhase;
5
+ // packages/phases/src/validate/check-customer-exists.ts
6
+ const integration_core_1 = require("@tonytang99/integration-core");
7
+ const bigcommerce_slots_1 = require("../slots/bigcommerce-slots");
8
+ const myob_slots_1 = require("../slots/myob-slots");
9
+ const processing_slots_1 = require("../slots/processing-slots");
10
+ /**
11
+ * Checks if a customer already exists in MYOB based on BC customer data
12
+ */
13
+ class CheckCustomerExistsPhase extends integration_core_1.BasePhase {
14
+ adapter;
15
+ config;
16
+ name = 'validate:check-customer-exists';
17
+ description = 'Checks if customer exists in MYOB';
18
+ tags = ['validate', 'customer', 'myob'];
19
+ requires = [
20
+ bigcommerce_slots_1.BigCommerceSlots.RAW_CUSTOMER,
21
+ ];
22
+ produces = [
23
+ myob_slots_1.MYOBSlots.CUSTOMER_EXISTS,
24
+ myob_slots_1.MYOBSlots.CUSTOMER_UID,
25
+ processing_slots_1.ProcessingSlots.SHOULD_CREATE_CUSTOMER,
26
+ ];
27
+ constructor(adapter, config = {}) {
28
+ super();
29
+ this.adapter = adapter;
30
+ this.config = config;
31
+ }
32
+ async execute(ctx) {
33
+ const bcCustomer = ctx.require(bigcommerce_slots_1.BigCommerceSlots.RAW_CUSTOMER);
34
+ const matchStrategy = this.config.matchStrategy ?? 'email';
35
+ let existingCustomer = null;
36
+ // Try to find customer based on match strategy
37
+ if (matchStrategy === 'email' || matchStrategy === 'both') {
38
+ if (bcCustomer.email) {
39
+ const result = await this.adapter.findCustomerByEmail(bcCustomer.email);
40
+ if (result.success && result.data) {
41
+ existingCustomer = result.data;
42
+ }
43
+ }
44
+ }
45
+ // If not found by email, try by name
46
+ if (!existingCustomer && (matchStrategy === 'name' || matchStrategy === 'both')) {
47
+ const result = await this.adapter.findCustomerByName(bcCustomer.first_name, bcCustomer.last_name);
48
+ if (result.success && result.data) {
49
+ existingCustomer = result.data;
50
+ }
51
+ }
52
+ const customerExists = existingCustomer !== null;
53
+ const customerUid = existingCustomer?.UID;
54
+ let result = ctx
55
+ .set(myob_slots_1.MYOBSlots.CUSTOMER_EXISTS, customerExists)
56
+ .set(processing_slots_1.ProcessingSlots.SHOULD_CREATE_CUSTOMER, !customerExists);
57
+ if (customerUid) {
58
+ result = result.set(myob_slots_1.MYOBSlots.CUSTOMER_UID, customerUid);
59
+ }
60
+ return result;
61
+ }
62
+ }
63
+ exports.CheckCustomerExistsPhase = CheckCustomerExistsPhase;
64
+ function createCheckCustomerExistsPhase(adapter, config) {
65
+ return new CheckCustomerExistsPhase(adapter, config);
66
+ }
67
+ //# sourceMappingURL=check-customer-exists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-customer-exists.js","sourceRoot":"","sources":["../../src/validate/check-customer-exists.ts"],"names":[],"mappings":";;;AAiFA,wEAKC;AAtFD,wDAAwD;AACxD,mEAAmF;AAEnF,kEAA8D;AAC9D,oDAAgD;AAChD,gEAA4D;AAU5D;;GAEG;AACH,MAAa,wBAAyB,SAAQ,4BAAS;IAe3C;IACA;IAfD,IAAI,GAAG,gCAAgC,CAAC;IACxC,WAAW,GAAG,mCAAmC,CAAC;IAClD,IAAI,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAExC,QAAQ,GAAuB;QACtC,oCAAgB,CAAC,YAAY;KAC9B,CAAC;IACO,QAAQ,GAAuB;QACtC,sBAAS,CAAC,eAAe;QACzB,sBAAS,CAAC,YAAY;QACtB,kCAAe,CAAC,sBAAsB;KACvC,CAAC;IAEF,YACU,OAA4B,EAC5B,SAAoC,EAAE;QAE9C,KAAK,EAAE,CAAC;QAHA,YAAO,GAAP,OAAO,CAAqB;QAC5B,WAAM,GAAN,MAAM,CAAgC;IAGhD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAoB;QAChC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,oCAAgB,CAAC,YAAY,CAAC,CAAC;QAC9D,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,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DC;AAED,SAAgB,8BAA8B,CAC5C,OAA4B,EAC5B,MAAkC;IAElC,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { VerifyNewOrderPhase, createVerifyNewOrderPhase } from './verify-new-order';
2
+ export type { VerifyNewOrderConfig } from './verify-new-order';
3
+ export { CheckCustomerExistsPhase, createCheckCustomerExistsPhase } from './check-customer-exists';
4
+ export type { CheckCustomerExistsConfig } from './check-customer-exists';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpF,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACnG,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // packages/phases/src/validate/index.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createCheckCustomerExistsPhase = exports.CheckCustomerExistsPhase = exports.createVerifyNewOrderPhase = exports.VerifyNewOrderPhase = void 0;
5
+ var verify_new_order_1 = require("./verify-new-order");
6
+ Object.defineProperty(exports, "VerifyNewOrderPhase", { enumerable: true, get: function () { return verify_new_order_1.VerifyNewOrderPhase; } });
7
+ Object.defineProperty(exports, "createVerifyNewOrderPhase", { enumerable: true, get: function () { return verify_new_order_1.createVerifyNewOrderPhase; } });
8
+ var check_customer_exists_1 = require("./check-customer-exists");
9
+ Object.defineProperty(exports, "CheckCustomerExistsPhase", { enumerable: true, get: function () { return check_customer_exists_1.CheckCustomerExistsPhase; } });
10
+ Object.defineProperty(exports, "createCheckCustomerExistsPhase", { enumerable: true, get: function () { return check_customer_exists_1.createCheckCustomerExistsPhase; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;AAExC,uDAAoF;AAA3E,uHAAA,mBAAmB,OAAA;AAAE,6HAAA,yBAAyB,OAAA;AAGvD,iEAAmG;AAA1F,iIAAA,wBAAwB,OAAA;AAAE,uIAAA,8BAA8B,OAAA"}
@@ -0,0 +1,27 @@
1
+ import { BasePhase, PipelineContext, SlotKey } from '@tonytang99/integration-core';
2
+ /**
3
+ * Configuration for order verification
4
+ */
5
+ export interface VerifyNewOrderConfig {
6
+ /** Statuses considered "new" (default: ['Pending', 'Awaiting Payment', 'Awaiting Fulfillment']) */
7
+ validStatuses?: string[];
8
+ /** Minimum order date (orders older than this are skipped) */
9
+ minOrderDate?: Date;
10
+ /** Whether to halt pipeline if order is not new */
11
+ haltIfNotNew?: boolean;
12
+ }
13
+ /**
14
+ * Verifies that an order should be processed (is new, valid status, etc.)
15
+ */
16
+ export declare class VerifyNewOrderPhase extends BasePhase {
17
+ private config;
18
+ readonly name = "validate:verify-new-order";
19
+ readonly description = "Verifies the order is new and should be processed";
20
+ readonly tags: string[];
21
+ readonly requires: SlotKey<unknown>[];
22
+ readonly produces: SlotKey<unknown>[];
23
+ constructor(config?: VerifyNewOrderConfig);
24
+ execute(ctx: PipelineContext): Promise<PipelineContext>;
25
+ }
26
+ export declare function createVerifyNewOrderPhase(config?: VerifyNewOrderConfig): VerifyNewOrderPhase;
27
+ //# sourceMappingURL=verify-new-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-new-order.d.ts","sourceRoot":"","sources":["../../src/validate/verify-new-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAInF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mGAAmG;IACnG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAID;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAYpC,OAAO,CAAC,MAAM;IAX1B,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,QAAQ,CAAC,WAAW,uDAAuD;IAC3E,QAAQ,CAAC,IAAI,WAAwC;IAErD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAgC;IACrE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAInC;gBAEkB,MAAM,GAAE,oBAAyB;IAI/C,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CA+B9D;AAED,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,mBAAmB,CAE5F"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerifyNewOrderPhase = void 0;
4
+ exports.createVerifyNewOrderPhase = createVerifyNewOrderPhase;
5
+ // packages/phases/src/validate/verify-new-order.ts
6
+ const integration_core_1 = require("@tonytang99/integration-core");
7
+ const bigcommerce_slots_1 = require("../slots/bigcommerce-slots");
8
+ const processing_slots_1 = require("../slots/processing-slots");
9
+ const DEFAULT_VALID_STATUSES = ['Pending', 'Awaiting Payment', 'Awaiting Fulfillment'];
10
+ /**
11
+ * Verifies that an order should be processed (is new, valid status, etc.)
12
+ */
13
+ class VerifyNewOrderPhase extends integration_core_1.BasePhase {
14
+ config;
15
+ name = 'validate:verify-new-order';
16
+ description = 'Verifies the order is new and should be processed';
17
+ tags = ['validate', 'order', 'bigcommerce'];
18
+ requires = [bigcommerce_slots_1.BigCommerceSlots.RAW_ORDER];
19
+ produces = [
20
+ processing_slots_1.ProcessingSlots.IS_NEW_ORDER,
21
+ processing_slots_1.ProcessingSlots.IS_VALID_ORDER,
22
+ processing_slots_1.ProcessingSlots.SHOULD_PROCESS,
23
+ ];
24
+ constructor(config = {}) {
25
+ super();
26
+ this.config = config;
27
+ }
28
+ async execute(ctx) {
29
+ const order = ctx.require(bigcommerce_slots_1.BigCommerceSlots.RAW_ORDER);
30
+ const validStatuses = this.config.validStatuses ?? DEFAULT_VALID_STATUSES;
31
+ // Check if order status is valid
32
+ const isValidStatus = validStatuses.includes(order.status);
33
+ // Check if order is within date range
34
+ let isWithinDateRange = true;
35
+ if (this.config.minOrderDate && order.date_created) {
36
+ const orderDate = new Date(order.date_created);
37
+ isWithinDateRange = orderDate >= this.config.minOrderDate;
38
+ }
39
+ const isNewOrder = isValidStatus && isWithinDateRange;
40
+ const shouldProcess = isNewOrder;
41
+ // If configured to halt and order is not new, fail the phase
42
+ if (this.config.haltIfNotNew && !isNewOrder) {
43
+ this.fail('ORDER_NOT_NEW', `Order ${order.id} is not a new order (status: ${order.status})`, false);
44
+ }
45
+ return ctx
46
+ .set(processing_slots_1.ProcessingSlots.IS_NEW_ORDER, isNewOrder)
47
+ .set(processing_slots_1.ProcessingSlots.IS_VALID_ORDER, isValidStatus)
48
+ .set(processing_slots_1.ProcessingSlots.SHOULD_PROCESS, shouldProcess);
49
+ }
50
+ }
51
+ exports.VerifyNewOrderPhase = VerifyNewOrderPhase;
52
+ function createVerifyNewOrderPhase(config) {
53
+ return new VerifyNewOrderPhase(config);
54
+ }
55
+ //# sourceMappingURL=verify-new-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-new-order.js","sourceRoot":"","sources":["../../src/validate/verify-new-order.ts"],"names":[],"mappings":";;;AAuEA,8DAEC;AAzED,mDAAmD;AACnD,mEAAmF;AACnF,kEAA8D;AAC9D,gEAA4D;AAc5D,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,kBAA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YAC5C,IAAI,CAAC,IAAI,CACP,eAAe,EACf,SAAS,KAAK,CAAC,EAAE,gCAAgC,KAAK,CAAC,MAAM,GAAG,EAChE,KAAK,CACN,CAAC;QACJ,CAAC;QAED,OAAO,GAAG;aACP,GAAG,CAAC,kCAAe,CAAC,YAAY,EAAE,UAAU,CAAC;aAC7C,GAAG,CAAC,kCAAe,CAAC,cAAc,EAAE,aAAa,CAAC;aAClD,GAAG,CAAC,kCAAe,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACF;AA/CD,kDA+CC;AAED,SAAgB,yBAAyB,CAAC,MAA6B;IACrE,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonytang99/integration-phases",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Pre-built phases for common integration patterns",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,9 @@
14
14
  "author": "tonytang99",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@tonytang99/integration-core": "^1.1.0",
18
- "@tonytang99/integration-canonical": "^1.1.0"
17
+ "@tonytang99/integration-core": "^1.2.0",
18
+ "@tonytang99/integration-canonical": "^1.2.0",
19
+ "@tonytang99/integration-adapters": "^1.2.0"
19
20
  },
20
21
  "devDependencies": {
21
22
  "typescript": "^5.2.0"