@flowcore/pathways 0.13.2 → 0.15.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.
- package/CHANGELOG.md +29 -0
- package/README.md +48 -45
- package/esm/contracts/event.d.ts +11 -19
- package/esm/contracts/event.d.ts.map +1 -1
- package/esm/contracts/event.js +1 -15
- package/esm/pathways/builder.d.ts +26 -18
- package/esm/pathways/builder.d.ts.map +1 -1
- package/esm/pathways/builder.js +57 -117
- package/esm/pathways/session-pathway.d.ts +5 -2
- package/esm/pathways/session-pathway.d.ts.map +1 -1
- package/esm/pathways/session-pathway.js +1 -1
- package/esm/pathways/types.d.ts +20 -3
- package/esm/pathways/types.d.ts.map +1 -1
- package/esm/pathways/types.js +18 -1
- package/package.json +4 -3
- package/script/contracts/event.d.ts +11 -19
- package/script/contracts/event.d.ts.map +1 -1
- package/script/contracts/event.js +0 -16
- package/script/pathways/builder.d.ts +26 -18
- package/script/pathways/builder.d.ts.map +1 -1
- package/script/pathways/builder.js +57 -117
- package/script/pathways/session-pathway.d.ts +5 -2
- package/script/pathways/session-pathway.d.ts.map +1 -1
- package/script/pathways/session-pathway.js +1 -1
- package/script/pathways/types.d.ts +20 -3
- package/script/pathways/types.d.ts.map +1 -1
- package/script/pathways/types.js +19 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathwaysBuilder = exports.SessionUser = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const file_type_1 = require("file-type");
|
|
6
6
|
const rxjs_1 = require("rxjs");
|
|
7
7
|
const flowcore_transformer_core_sdk_js_1 = require("../compatibility/flowcore-transformer-core.sdk.js");
|
|
8
8
|
const internal_pathway_state_js_1 = require("./internal-pathway.state.js");
|
|
9
9
|
const logger_js_1 = require("./logger.js");
|
|
10
10
|
const constants_js_1 = require("./constants.js");
|
|
11
|
+
const types_js_1 = require("./types.js");
|
|
11
12
|
/**
|
|
12
13
|
* Default timeout for pathway processing in milliseconds (10 seconds)
|
|
13
14
|
*/
|
|
@@ -157,12 +158,24 @@ class PathwaysBuilder {
|
|
|
157
158
|
writable: true,
|
|
158
159
|
value: {}
|
|
159
160
|
});
|
|
161
|
+
Object.defineProperty(this, "fileWriters", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
configurable: true,
|
|
164
|
+
writable: true,
|
|
165
|
+
value: {}
|
|
166
|
+
});
|
|
160
167
|
Object.defineProperty(this, "schemas", {
|
|
161
168
|
enumerable: true,
|
|
162
169
|
configurable: true,
|
|
163
170
|
writable: true,
|
|
164
171
|
value: {}
|
|
165
172
|
});
|
|
173
|
+
Object.defineProperty(this, "inputSchemas", {
|
|
174
|
+
enumerable: true,
|
|
175
|
+
configurable: true,
|
|
176
|
+
writable: true,
|
|
177
|
+
value: {}
|
|
178
|
+
});
|
|
166
179
|
Object.defineProperty(this, "writable", {
|
|
167
180
|
enumerable: true,
|
|
168
181
|
configurable: true,
|
|
@@ -273,7 +286,7 @@ class PathwaysBuilder {
|
|
|
273
286
|
this.logger = logger ?? new logger_js_1.NoopLogger();
|
|
274
287
|
// Initialize log levels with defaults
|
|
275
288
|
this.logLevel = {
|
|
276
|
-
writeSuccess: logLevel?.writeSuccess ??
|
|
289
|
+
writeSuccess: logLevel?.writeSuccess ?? "info",
|
|
277
290
|
};
|
|
278
291
|
// Store configuration values for cloning
|
|
279
292
|
this.baseUrl = baseUrl;
|
|
@@ -406,9 +419,9 @@ class PathwaysBuilder {
|
|
|
406
419
|
}
|
|
407
420
|
// Validate event payload against schema if available
|
|
408
421
|
if (this.schemas[pathway]) {
|
|
422
|
+
const parsedPayload = this.schemas[pathway].safeParse(data.payload);
|
|
409
423
|
try {
|
|
410
|
-
|
|
411
|
-
if (!isValid) {
|
|
424
|
+
if (!parsedPayload.success) {
|
|
412
425
|
const error = `Event payload does not match schema for pathway ${pathwayStr}`;
|
|
413
426
|
this.logger.error(error);
|
|
414
427
|
throw new Error(error);
|
|
@@ -419,6 +432,7 @@ class PathwaysBuilder {
|
|
|
419
432
|
this.logger.error(error);
|
|
420
433
|
throw new Error(error);
|
|
421
434
|
}
|
|
435
|
+
data.payload = parsedPayload.data;
|
|
422
436
|
}
|
|
423
437
|
// Call audit handler if configured
|
|
424
438
|
if (this.auditHandler) {
|
|
@@ -519,7 +533,7 @@ class PathwaysBuilder {
|
|
|
519
533
|
* Registers a new pathway with the given contract
|
|
520
534
|
* @template F The flow type string
|
|
521
535
|
* @template E The event type string
|
|
522
|
-
* @template S The schema type extending
|
|
536
|
+
* @template S The schema type extending ZodTypeAny
|
|
523
537
|
* @template W Boolean indicating if the pathway is writable (defaults to true)
|
|
524
538
|
* @param contract The pathway contract describing the pathway
|
|
525
539
|
* @returns The PathwaysBuilder instance with the new pathway registered
|
|
@@ -545,14 +559,15 @@ class PathwaysBuilder {
|
|
|
545
559
|
if (writable) {
|
|
546
560
|
if (contract.isFilePathway) {
|
|
547
561
|
this.filePathways.add(path);
|
|
548
|
-
this.
|
|
562
|
+
this.fileWriters[path] = this.webhookBuilderFactory()
|
|
549
563
|
.buildFileWebhook(contract.flowType, contract.eventType).send;
|
|
550
564
|
}
|
|
551
565
|
else {
|
|
552
566
|
this.writers[path] = this.webhookBuilderFactory()
|
|
553
567
|
.buildWebhook(contract.flowType, contract.eventType).send;
|
|
554
568
|
this.batchWriters[path] = this.webhookBuilderFactory()
|
|
555
|
-
.buildWebhook(contract.flowType, contract.eventType)
|
|
569
|
+
.buildWebhook(contract.flowType, contract.eventType)
|
|
570
|
+
.sendBatch;
|
|
556
571
|
}
|
|
557
572
|
}
|
|
558
573
|
if (contract.timeoutMs) {
|
|
@@ -564,13 +579,21 @@ class PathwaysBuilder {
|
|
|
564
579
|
if (contract.retryDelayMs !== undefined) {
|
|
565
580
|
this.retryDelays[path] = contract.retryDelayMs;
|
|
566
581
|
}
|
|
567
|
-
|
|
582
|
+
if (contract.isFilePathway) {
|
|
583
|
+
this.schemas[path] = (contract.schema ?? zod_1.z.object({})).merge(types_js_1.FileEventSchema);
|
|
584
|
+
this.inputSchemas[path] = (contract.schema ?? zod_1.z.object({})).merge(types_js_1.FileInputSchema);
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
this.schemas[path] = contract.schema ?? zod_1.z.object({});
|
|
588
|
+
this.inputSchemas[path] = contract.schema ?? zod_1.z.object({});
|
|
589
|
+
}
|
|
568
590
|
this.writable[path] = writable;
|
|
569
591
|
this.logger.info(`Pathway registered successfully`, {
|
|
570
592
|
pathway: path,
|
|
571
593
|
flowType: contract.flowType,
|
|
572
594
|
eventType: contract.eventType,
|
|
573
595
|
writable,
|
|
596
|
+
isFilePathway: contract.isFilePathway,
|
|
574
597
|
});
|
|
575
598
|
return this;
|
|
576
599
|
}
|
|
@@ -681,8 +704,14 @@ class PathwaysBuilder {
|
|
|
681
704
|
* @param options Optional write options
|
|
682
705
|
* @returns A promise that resolves to the event ID(s)
|
|
683
706
|
*/
|
|
684
|
-
async write(path,
|
|
707
|
+
async write(path, input) {
|
|
685
708
|
const pathStr = String(path);
|
|
709
|
+
const { data: inputData, metadata, options, batch } = input;
|
|
710
|
+
if (batch && this.filePathways.has(path)) {
|
|
711
|
+
const error = `Batch is not possible for file pathways. Pathway ${pathStr} is a file pathway`;
|
|
712
|
+
this.logger.error(error);
|
|
713
|
+
throw new Error(error);
|
|
714
|
+
}
|
|
686
715
|
this.logger.debug(`Writing to pathway`, {
|
|
687
716
|
pathway: pathStr,
|
|
688
717
|
metadata,
|
|
@@ -701,8 +730,9 @@ class PathwaysBuilder {
|
|
|
701
730
|
this.logger.error(error);
|
|
702
731
|
throw new Error(error);
|
|
703
732
|
}
|
|
704
|
-
const schema = this.
|
|
705
|
-
|
|
733
|
+
const schema = batch ? zod_1.z.array(this.inputSchemas[path]) : this.inputSchemas[path];
|
|
734
|
+
const parsedData = schema.safeParse(inputData);
|
|
735
|
+
if (!parsedData.success) {
|
|
706
736
|
const errorMessage = `Invalid data for pathway ${pathStr}`;
|
|
707
737
|
this.logger.error(errorMessage, new Error(errorMessage), {
|
|
708
738
|
pathway: pathStr,
|
|
@@ -710,6 +740,7 @@ class PathwaysBuilder {
|
|
|
710
740
|
});
|
|
711
741
|
throw new Error(errorMessage);
|
|
712
742
|
}
|
|
743
|
+
const data = parsedData.data;
|
|
713
744
|
// Create a copy of the metadata to avoid modifying the original
|
|
714
745
|
const finalMetadata = metadata ? { ...metadata } : {};
|
|
715
746
|
// Check for session-specific user resolver
|
|
@@ -763,13 +794,22 @@ class PathwaysBuilder {
|
|
|
763
794
|
}
|
|
764
795
|
}
|
|
765
796
|
let eventIds = [];
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
797
|
+
this.logger.debug(`Writing webhook data to pathway`, { pathway: pathStr, batch });
|
|
798
|
+
if (batch) {
|
|
799
|
+
eventIds = await this.batchWriters[path](data, finalMetadata, options);
|
|
800
|
+
}
|
|
801
|
+
else if (this.filePathways.has(path)) {
|
|
802
|
+
const { fileId, fileName, fileContent, ...additionalProperties } = data;
|
|
803
|
+
const fileType = await (0, file_type_1.fileTypeFromBuffer)(fileContent);
|
|
804
|
+
eventIds = await this.fileWriters[path]({
|
|
805
|
+
fileId,
|
|
806
|
+
fileName,
|
|
807
|
+
fileType: fileType?.mime ?? "application/octet-stream",
|
|
808
|
+
fileContent: new Blob([fileContent]),
|
|
809
|
+
additionalProperties,
|
|
810
|
+
}, finalMetadata, options);
|
|
770
811
|
}
|
|
771
812
|
else {
|
|
772
|
-
this.logger.debug(`Writing webhook data to pathway`, { pathway: pathStr });
|
|
773
813
|
eventIds = await this.writers[path](data, finalMetadata, options);
|
|
774
814
|
}
|
|
775
815
|
this.logger[this.logLevel.writeSuccess](`Successfully wrote to pathway`, {
|
|
@@ -788,106 +828,6 @@ class PathwaysBuilder {
|
|
|
788
828
|
}
|
|
789
829
|
return eventIds;
|
|
790
830
|
}
|
|
791
|
-
async writeBatch(path, data, metadata, options) {
|
|
792
|
-
const pathStr = String(path);
|
|
793
|
-
this.logger.debug(`Writing batch to pathway`, {
|
|
794
|
-
pathway: pathStr,
|
|
795
|
-
metadata,
|
|
796
|
-
options: {
|
|
797
|
-
fireAndForget: options?.fireAndForget,
|
|
798
|
-
sessionId: options?.sessionId,
|
|
799
|
-
},
|
|
800
|
-
});
|
|
801
|
-
if (!this.pathways[path]) {
|
|
802
|
-
const error = `Pathway ${pathStr} not found`;
|
|
803
|
-
this.logger.error(error);
|
|
804
|
-
throw new Error(error);
|
|
805
|
-
}
|
|
806
|
-
if (!this.writable[path]) {
|
|
807
|
-
const error = `Pathway ${pathStr} is not writable`;
|
|
808
|
-
this.logger.error(error);
|
|
809
|
-
throw new Error(error);
|
|
810
|
-
}
|
|
811
|
-
const schema = this.schemas[path];
|
|
812
|
-
if (!value_1.Value.Check(typebox_1.Type.Array(schema), data)) {
|
|
813
|
-
const errorMessage = `Invalid batch data for pathway ${pathStr}`;
|
|
814
|
-
this.logger.error(errorMessage, new Error(errorMessage), {
|
|
815
|
-
pathway: pathStr,
|
|
816
|
-
schema: schema.toString(),
|
|
817
|
-
});
|
|
818
|
-
throw new Error(errorMessage);
|
|
819
|
-
}
|
|
820
|
-
// Create a copy of the metadata to avoid modifying the original
|
|
821
|
-
const finalMetadata = metadata ? { ...metadata } : {};
|
|
822
|
-
// Check for session-specific user resolver
|
|
823
|
-
let userId;
|
|
824
|
-
if (options?.sessionId) {
|
|
825
|
-
const sessionUserResolver = this.getSessionUserResolver(options.sessionId);
|
|
826
|
-
if (sessionUserResolver) {
|
|
827
|
-
try {
|
|
828
|
-
userId = await sessionUserResolver();
|
|
829
|
-
this.logger.debug(`Using session-specific user resolver`, {
|
|
830
|
-
pathway: pathStr,
|
|
831
|
-
sessionId: options.sessionId,
|
|
832
|
-
userId,
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
catch (error) {
|
|
836
|
-
this.logger.error(`Error resolving session user ID`, error instanceof Error ? error : new Error(String(error)), {
|
|
837
|
-
pathway: pathStr,
|
|
838
|
-
sessionId: options.sessionId,
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
// Process audit metadata if audit is configured
|
|
844
|
-
if (this.userIdResolver) {
|
|
845
|
-
// Only use global resolver if we don't already have a user ID from a session resolver
|
|
846
|
-
if (!userId) {
|
|
847
|
-
this.logger.debug(`Resolving user ID for audit metadata`, { pathway: pathStr });
|
|
848
|
-
userId = await this.userIdResolver();
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
// Determine the audit mode: default is "user" unless explicitly specified as "system"
|
|
852
|
-
const auditMode = options?.auditMode ?? "user";
|
|
853
|
-
this.logger.debug(`Adding audit metadata`, {
|
|
854
|
-
pathway: pathStr,
|
|
855
|
-
auditMode,
|
|
856
|
-
userId,
|
|
857
|
-
});
|
|
858
|
-
if (userId) {
|
|
859
|
-
// Add appropriate audit metadata based on mode
|
|
860
|
-
if (auditMode === constants_js_1.AUDIT_SYSTEM_MODE) {
|
|
861
|
-
finalMetadata[constants_js_1.AUDIT_USER_ID] = "system";
|
|
862
|
-
finalMetadata[constants_js_1.AUDIT_ON_BEHALF_OF] = userId.entityId;
|
|
863
|
-
finalMetadata[constants_js_1.AUDIT_MODE] = "system";
|
|
864
|
-
finalMetadata[constants_js_1.AUDIT_ENTITY_TYPE] = userId.entityType;
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
finalMetadata[constants_js_1.AUDIT_USER_ID] = userId.entityId;
|
|
868
|
-
finalMetadata[constants_js_1.AUDIT_MODE] = constants_js_1.AUDIT_USER_MODE; // Always set mode for user
|
|
869
|
-
finalMetadata[constants_js_1.AUDIT_ENTITY_TYPE] = userId.entityType;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
let eventIds = [];
|
|
873
|
-
this.logger.debug(`Writing batch webhook data to pathway`, { pathway: pathStr });
|
|
874
|
-
eventIds = await this.batchWriters[path](data, finalMetadata, options);
|
|
875
|
-
this.logger[this.logLevel.writeSuccess](`Successfully wrote to pathway`, {
|
|
876
|
-
pathway: pathStr,
|
|
877
|
-
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
878
|
-
fireAndForget: options?.fireAndForget,
|
|
879
|
-
});
|
|
880
|
-
if (!options?.fireAndForget) {
|
|
881
|
-
this.logger.debug(`Waiting for pathway to be processed`, {
|
|
882
|
-
pathway: pathStr,
|
|
883
|
-
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
884
|
-
});
|
|
885
|
-
await Promise.all(Array.isArray(eventIds)
|
|
886
|
-
? eventIds.map((id) => this.waitForPathwayToBeProcessed(id))
|
|
887
|
-
: [this.waitForPathwayToBeProcessed(eventIds)]);
|
|
888
|
-
}
|
|
889
|
-
return eventIds;
|
|
890
|
-
}
|
|
891
831
|
/**
|
|
892
832
|
* Waits for a specific event to be processed
|
|
893
833
|
*
|
|
@@ -39,7 +39,10 @@ import type { EventMetadata, PathwayWriteOptions } from "./types.js";
|
|
|
39
39
|
* // All events will be associated with the same session ID
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
export declare class SessionPathwayBuilder<TPathway extends Record<string,
|
|
42
|
+
export declare class SessionPathwayBuilder<TPathway extends Record<string, {
|
|
43
|
+
input: unknown;
|
|
44
|
+
output: unknown;
|
|
45
|
+
}> = {}, TWritablePaths extends keyof TPathway = never> {
|
|
43
46
|
private readonly pathwaysBuilder;
|
|
44
47
|
private readonly sessionId;
|
|
45
48
|
/**
|
|
@@ -94,6 +97,6 @@ export declare class SessionPathwayBuilder<TPathway extends Record<string, unkno
|
|
|
94
97
|
* @param options Optional write options
|
|
95
98
|
* @returns A promise that resolves to the event ID(s)
|
|
96
99
|
*/
|
|
97
|
-
write<TPath extends TWritablePaths>(path: TPath, data: TPathway[TPath], metadata?: EventMetadata, options?: PathwayWriteOptions): Promise<string | string[]>;
|
|
100
|
+
write<TPath extends TWritablePaths>(path: TPath, data: TPathway[TPath]["input"], metadata?: EventMetadata, options?: PathwayWriteOptions): Promise<string | string[]>;
|
|
98
101
|
}
|
|
99
102
|
//# sourceMappingURL=session-pathway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-pathway.d.ts","sourceRoot":"","sources":["../../src/pathways/session-pathway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAqBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,qBAAqB,CAEhC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"session-pathway.d.ts","sourceRoot":"","sources":["../../src/pathways/session-pathway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAqBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,qBAAqB,CAEhC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,EAAE,EACzE,cAAc,SAAS,MAAM,QAAQ,GAAG,KAAK;IAE7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA2C;IAC3E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC;;;;;OAKG;gBAED,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,EAC1D,SAAS,CAAC,EAAE,MAAM;IAMpB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAKhD;;;;;;;;OAQG;IACG,KAAK,CAAC,KAAK,SAAS,cAAc,EACtC,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAC9B,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;CAU9B"}
|
|
@@ -136,7 +136,7 @@ class SessionPathwayBuilder {
|
|
|
136
136
|
// Always include the session ID in the options
|
|
137
137
|
finalOptions.sessionId = options?.sessionId ?? this.sessionId;
|
|
138
138
|
// The PathwaysBuilder will handle session-specific user resolvers
|
|
139
|
-
return await this.pathwaysBuilder.write(path, data, metadata, finalOptions);
|
|
139
|
+
return await this.pathwaysBuilder.write(path, { data, metadata, options: finalOptions });
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
exports.SessionPathwayBuilder = SessionPathwayBuilder;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyZodObject, z } from "zod";
|
|
2
2
|
import type { WebhookFileData, WebhookSendOptions } from "@flowcore/sdk-transformer-core";
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
3
4
|
/**
|
|
4
5
|
* Helper type to create a custom type error for non-writable pathways
|
|
5
6
|
* @template T The string type to create an error for
|
|
@@ -13,7 +14,7 @@ type NonWritablePathwayError<T extends string> = T & {
|
|
|
13
14
|
* @template E The event type
|
|
14
15
|
* @template T The schema type
|
|
15
16
|
*/
|
|
16
|
-
export interface PathwayContract<F extends string, E extends string, T extends
|
|
17
|
+
export interface PathwayContract<F extends string, E extends string, T extends AnyZodObject> {
|
|
17
18
|
/**
|
|
18
19
|
* The flow type for this pathway
|
|
19
20
|
*/
|
|
@@ -25,7 +26,7 @@ export interface PathwayContract<F extends string, E extends string, T extends T
|
|
|
25
26
|
/**
|
|
26
27
|
* The schema that defines the structure of events for this pathway
|
|
27
28
|
*/
|
|
28
|
-
schema
|
|
29
|
+
schema?: T;
|
|
29
30
|
/**
|
|
30
31
|
* Whether the pathway is writable. Use `false as const` to make the pathway non-writable at compile time.
|
|
31
32
|
* @example
|
|
@@ -143,5 +144,21 @@ export type PathwayWriteOptions = WebhookSendOptions & {
|
|
|
143
144
|
*/
|
|
144
145
|
sessionId?: string;
|
|
145
146
|
};
|
|
147
|
+
export declare const FileInputSchema: z.ZodObject<{
|
|
148
|
+
fileId: z.ZodString;
|
|
149
|
+
fileName: z.ZodString;
|
|
150
|
+
fileContent: z.ZodType<Buffer>;
|
|
151
|
+
}>;
|
|
152
|
+
export declare const FileEventSchema: z.ZodObject<{
|
|
153
|
+
fileName: z.ZodString;
|
|
154
|
+
fileType: z.ZodString;
|
|
155
|
+
fileSize: z.ZodNumber;
|
|
156
|
+
data: z.ZodString;
|
|
157
|
+
part: z.ZodNumber;
|
|
158
|
+
totalParts: z.ZodNumber;
|
|
159
|
+
checksum: z.ZodString;
|
|
160
|
+
hashType: z.ZodString;
|
|
161
|
+
fileId: z.ZodString;
|
|
162
|
+
}>;
|
|
146
163
|
export {};
|
|
147
164
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pathways/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pathways/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,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Ae,EAAE,CAAC,CAAC,SAAS,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;IACrB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;IACrB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;IACrB,IAAI,EAAE,CAAC,CAAC,SAAS,CAAA;IACjB,IAAI,EAAE,CAAC,CAAC,SAAS,CAAA;IACjB,UAAU,EAAE,CAAC,CAAC,SAAS,CAAA;IACvB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;IACrB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;IACrB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAA;CACpB,CAUC,CAAA"}
|
package/script/pathways/types.js
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileEventSchema = exports.FileInputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const node_buffer_1 = require("node:buffer");
|
|
6
|
+
exports.FileInputSchema = zod_1.z.object({
|
|
7
|
+
fileId: zod_1.z.string(),
|
|
8
|
+
fileName: zod_1.z.string(),
|
|
9
|
+
fileContent: zod_1.z.instanceof(node_buffer_1.Buffer),
|
|
10
|
+
});
|
|
11
|
+
exports.FileEventSchema = zod_1.z.object({
|
|
12
|
+
fileName: zod_1.z.string(),
|
|
13
|
+
fileType: zod_1.z.string(),
|
|
14
|
+
fileSize: zod_1.z.number(),
|
|
15
|
+
data: zod_1.z.string(),
|
|
16
|
+
part: zod_1.z.number(),
|
|
17
|
+
totalParts: zod_1.z.number(),
|
|
18
|
+
checksum: zod_1.z.string(),
|
|
19
|
+
hashType: zod_1.z.string(),
|
|
20
|
+
fileId: zod_1.z.string(),
|
|
21
|
+
});
|