@runlane/lane-postgres-sqs 0.3.0 → 0.5.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/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16,23 +16,26 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let _runlane_contracts = require("@runlane/contracts");
25
24
  let _runlane_postgres_storage = require("@runlane/postgres-storage");
26
25
  let _runlane_transport_sqs = require("@runlane/transport-sqs");
27
26
  let _runlane_utilities = require("@runlane/utilities");
28
27
  let zod = require("zod");
29
28
  zod = __toESM(zod, 1);
30
- //#region src/postgres-sqs-lane.ts
29
+ // src/postgres-sqs-lane.ts
31
30
  const postgresSqsLaneOptionsSchema = zod.strictObject({
31
+ runHints: zod.boolean("runHints must be a boolean.").optional(),
32
32
  name: zod.string(_runlane_contracts.contractValidationMessages.lane.name).min(1, _runlane_contracts.contractValidationMessages.lane.name).optional(),
33
- postgres: zod.unknown().refine((postgresOptions) => postgresOptions !== void 0, { message: "Postgres SQS lane postgres options are required." }),
33
+ postgres: zod.looseObject({ runSignalNotifications: zod.never("Use runHints on a Postgres SQS lane.").optional() }, "Postgres SQS lane postgres options are required."),
34
34
  sqs: zod.unknown().refine((sqsOptions) => sqsOptions !== void 0, { message: "Postgres SQS lane sqs options are required." })
35
35
  });
36
+ /**
37
+ * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.
38
+ */
36
39
  function postgresSqsLane(options) {
37
40
  const laneOptions = (0, _runlane_utilities.parseZodOrThrow)(postgresSqsLaneOptionsSchema, options, (error) => new _runlane_contracts.RunlaneError({
38
41
  code: _runlane_contracts.ErrorCode.ConfigurationInvalid,
@@ -40,26 +43,38 @@ function postgresSqsLane(options) {
40
43
  fallbackMessage: "Postgres SQS lane options must be an object.",
41
44
  fieldMessages: {
42
45
  name: _runlane_contracts.contractValidationMessages.lane.name,
43
- postgres: "Postgres SQS lane postgres options are required.",
44
46
  sqs: "Postgres SQS lane sqs options are required."
45
47
  },
46
48
  rootMessage: "Postgres SQS lane options must be an object.",
47
49
  unsupportedKeyMessage: (option) => `Postgres SQS lane option "${option}" is not supported.`
48
50
  })
49
51
  }));
50
- const transport = (0, _runlane_transport_sqs.sqsTransport)(laneOptions.sqs);
51
- const storage = (0, _runlane_postgres_storage.postgresStorage)(laneOptions.postgres);
52
+ const deliveryProvider = (0, _runlane_transport_sqs.createSqsDeliveryProvider)(options.sqs);
53
+ const postgresOptions = options.postgres;
54
+ const postgresConfig = (0, _runlane_postgres_storage.resolvePostgresStorageConfig)({
55
+ connectionString: postgresOptions.connectionString,
56
+ schema: postgresOptions.schema
57
+ });
58
+ const hints = laneOptions.runHints ?? _runlane_contracts.contractDefaults.realtime.runHints;
59
+ const storage = (0, _runlane_postgres_storage.createPostgresStorageDriver)({
60
+ ...postgresOptions,
61
+ runSignalNotifications: hints,
62
+ workSignalNotifications: postgresOptions.workSignalNotifications ?? false
63
+ });
52
64
  return (0, _runlane_contracts.createLane)({
65
+ cli: [(0, _runlane_postgres_storage.createPostgresCliAdapter)(postgresConfig)],
53
66
  delivery: {
54
67
  mode: _runlane_contracts.LaneDeliveryMode.Transport,
55
- transport
68
+ publisher: deliveryProvider.publisher,
69
+ surface: deliveryProvider.surface
56
70
  },
57
71
  name: laneOptions.name ?? "postgres-sqs",
58
- productionDurable: true,
72
+ operatorReads: storage,
73
+ runSignal: hints ? storage.runSignal : void 0,
74
+ queues: deliveryProvider.queues,
59
75
  storage
60
76
  });
61
77
  }
62
- //#endregion
63
78
  exports.postgresSqsLane = postgresSqsLane;
64
79
 
65
80
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["z","contractValidationMessages","RunlaneError","ErrorCode","LaneDeliveryMode"],"sources":["../src/postgres-sqs-lane.ts"],"sourcesContent":["import {\n contractValidationMessages,\n createLane,\n ErrorCode,\n LaneDeliveryMode,\n RunlaneError,\n type Lane,\n} from '@runlane/contracts'\nimport { postgresStorage, type PostgresStorageOptions } from '@runlane/postgres-storage'\nimport { sqsTransport, type SqsTransportOptions } from '@runlane/transport-sqs'\nimport { getZodIssueMessage, parseZodOrThrow } from '@runlane/utilities'\nimport * as z from 'zod'\n\nenum PostgresSqsLaneValidationMessage {\n OptionsObject = 'Postgres SQS lane options must be an object.',\n PostgresRequired = 'Postgres SQS lane postgres options are required.',\n SqsRequired = 'Postgres SQS lane sqs options are required.',\n}\n\nconst postgresSqsLaneOptionsSchema = z.strictObject({\n name: z.string(contractValidationMessages.lane.name).min(1, contractValidationMessages.lane.name).optional(),\n postgres: z.unknown().refine((postgresOptions) => postgresOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.PostgresRequired,\n }),\n sqs: z.unknown().refine((sqsOptions) => sqsOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.SqsRequired,\n }),\n})\n\n/**\n * Construction options for the first-party production Postgres/SQS lane.\n *\n * Postgres and SQS nested options are validated by their owning adapter packages.\n */\nexport type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {\n readonly postgres: PostgresStorageOptions\n readonly sqs: SqsTransportOptions\n}\n\n/**\n * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.\n */\nexport function postgresSqsLane(options: PostgresSqsLaneOptions): Lane\nexport function postgresSqsLane(options: unknown): Lane {\n const laneOptions = parseZodOrThrow(\n postgresSqsLaneOptionsSchema,\n options,\n (error) =>\n new RunlaneError({\n code: ErrorCode.ConfigurationInvalid,\n message: getZodIssueMessage(error.issues[0], {\n fallbackMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n fieldMessages: {\n name: contractValidationMessages.lane.name,\n postgres: PostgresSqsLaneValidationMessage.PostgresRequired,\n sqs: PostgresSqsLaneValidationMessage.SqsRequired,\n },\n rootMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n unsupportedKeyMessage: (option) => `Postgres SQS lane option \"${option}\" is not supported.`,\n }),\n }),\n )\n const transport = sqsTransport(laneOptions.sqs as SqsTransportOptions)\n const storage = postgresStorage(laneOptions.postgres as PostgresStorageOptions)\n\n return createLane({\n delivery: { mode: LaneDeliveryMode.Transport, transport },\n name: laneOptions.name ?? 'postgres-sqs',\n productionDurable: true,\n storage,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,+BAA+BA,IAAE,aAAa;CAClD,MAAMA,IAAE,OAAOC,mBAAAA,2BAA2B,KAAK,IAAI,EAAE,IAAI,GAAGA,mBAAAA,2BAA2B,KAAK,IAAI,EAAE,SAAS;CAC3G,UAAUD,IAAE,QAAQ,EAAE,QAAQ,oBAAoB,oBAAoB,KAAA,GAAW,EAC/E,SAAA,mDACF,CAAC;CACD,KAAKA,IAAE,QAAQ,EAAE,QAAQ,eAAe,eAAe,KAAA,GAAW,EAChE,SAAA,8CACF,CAAC;AACH,CAAC;AAgBD,SAAgB,gBAAgB,SAAwB;CACtD,MAAM,eAAA,GAAA,mBAAA,iBACJ,8BACA,UACC,UACC,IAAIE,mBAAAA,aAAa;EACf,MAAMC,mBAAAA,UAAU;EAChB,UAAA,GAAA,mBAAA,oBAA4B,MAAM,OAAO,IAAI;GAC3C,iBAAA;GACA,eAAe;IACb,MAAMF,mBAAAA,2BAA2B,KAAK;IACtC,UAAA;IACA,KAAA;GACF;GACA,aAAA;GACA,wBAAwB,WAAW,6BAA6B,OAAO;EACzE,CAAC;CACH,CAAC,CACL;CACA,MAAM,aAAA,GAAA,uBAAA,cAAyB,YAAY,GAA0B;CACrE,MAAM,WAAA,GAAA,0BAAA,iBAA0B,YAAY,QAAkC;CAE9E,QAAA,GAAA,mBAAA,YAAkB;EAChB,UAAU;GAAE,MAAMG,mBAAAA,iBAAiB;GAAW;EAAU;EACxD,MAAM,YAAY,QAAQ;EAC1B,mBAAmB;EACnB;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["z","contractValidationMessages","parseZodOrThrow","RunlaneError","ErrorCode","getZodIssueMessage","createSqsDeliveryProvider","resolvePostgresStorageConfig","contractDefaults","createPostgresStorageDriver","createLane","createPostgresCliAdapter","LaneDeliveryMode"],"sources":["../src/postgres-sqs-lane.ts"],"sourcesContent":["import {\n contractDefaults,\n contractValidationMessages,\n createLane,\n ErrorCode,\n LaneDeliveryMode,\n RunlaneError,\n type TransportLane,\n} from '@runlane/contracts'\nimport {\n createPostgresCliAdapter,\n createPostgresStorageDriver,\n resolvePostgresStorageConfig,\n type PostgresStorageDriverOptions,\n} from '@runlane/postgres-storage'\nimport { createSqsDeliveryProvider, type SqsLambdaHandler, type SqsTransportOptions } from '@runlane/transport-sqs'\nimport { getZodIssueMessage, parseZodOrThrow } from '@runlane/utilities'\nimport * as z from 'zod'\n\nenum PostgresSqsLaneValidationMessage {\n OptionsObject = 'Postgres SQS lane options must be an object.',\n PostgresRequired = 'Postgres SQS lane postgres options are required.',\n SqsRequired = 'Postgres SQS lane sqs options are required.',\n}\n\nconst postgresSqsLaneOptionsSchema = z.strictObject({\n runHints: z.boolean('runHints must be a boolean.').optional(),\n name: z.string(contractValidationMessages.lane.name).min(1, contractValidationMessages.lane.name).optional(),\n postgres: z.looseObject(\n { runSignalNotifications: z.never('Use runHints on a Postgres SQS lane.').optional() },\n PostgresSqsLaneValidationMessage.PostgresRequired,\n ),\n sqs: z.unknown().refine((sqsOptions) => sqsOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.SqsRequired,\n }),\n})\n\n/**\n * Construction options for the first-party production Postgres/SQS lane.\n *\n * runHints defaults to true; set false for serverless consumers to avoid a dedicated connection.\n * Postgres and SQS nested options are validated by their owning adapter packages.\n */\nexport type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {\n readonly postgres: Omit<PostgresStorageDriverOptions, 'runSignalNotifications'>\n readonly sqs: SqsTransportOptions\n}\n\n/**\n * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.\n */\nexport function postgresSqsLane(options: PostgresSqsLaneOptions): TransportLane<SqsLambdaHandler> {\n const laneOptions = parseZodOrThrow(\n postgresSqsLaneOptionsSchema,\n options,\n (error) =>\n new RunlaneError({\n code: ErrorCode.ConfigurationInvalid,\n message: getZodIssueMessage(error.issues[0], {\n fallbackMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n fieldMessages: {\n name: contractValidationMessages.lane.name,\n sqs: PostgresSqsLaneValidationMessage.SqsRequired,\n },\n rootMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n unsupportedKeyMessage: (option) => `Postgres SQS lane option \"${option}\" is not supported.`,\n }),\n }),\n )\n const deliveryProvider = createSqsDeliveryProvider(options.sqs)\n const postgresOptions = options.postgres\n const postgresConfig = resolvePostgresStorageConfig({\n connectionString: postgresOptions.connectionString,\n schema: postgresOptions.schema,\n })\n // Nothing on this lane listens for PostgreSQL work signals; SQS carries every wakeup.\n const hints = laneOptions.runHints ?? contractDefaults.realtime.runHints\n const storage = createPostgresStorageDriver({\n ...postgresOptions,\n runSignalNotifications: hints,\n workSignalNotifications: postgresOptions.workSignalNotifications ?? false,\n })\n\n return createLane({\n cli: [createPostgresCliAdapter(postgresConfig)],\n delivery: {\n mode: LaneDeliveryMode.Transport,\n publisher: deliveryProvider.publisher,\n surface: deliveryProvider.surface,\n },\n name: laneOptions.name ?? 'postgres-sqs',\n operatorReads: storage,\n runSignal: hints ? storage.runSignal : undefined,\n queues: deliveryProvider.queues,\n storage,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,+BAA+BA,IAAE,aAAa;CAClD,UAAUA,IAAE,QAAQ,6BAA6B,CAAC,CAAC,SAAS;CAC5D,MAAMA,IAAE,OAAOC,mBAAAA,2BAA2B,KAAK,IAAI,CAAC,CAAC,IAAI,GAAGA,mBAAAA,2BAA2B,KAAK,IAAI,CAAC,CAAC,SAAS;CAC3G,UAAUD,IAAE,YACV,EAAE,wBAAwBA,IAAE,MAAM,sCAAsC,CAAC,CAAC,SAAS,EAAE,GAAA,kDAEvF;CACA,KAAKA,IAAE,QAAQ,CAAC,CAAC,QAAQ,eAAe,eAAe,KAAA,GAAW,EAChE,SAAA,8CACF,CAAC;AACH,CAAC;;;;AAgBD,SAAgB,gBAAgB,SAAkE;CAChG,MAAM,eAAA,GAAcE,mBAAAA,gBAAAA,CAClB,8BACA,UACC,UACC,IAAIC,mBAAAA,aAAa;EACf,MAAMC,mBAAAA,UAAU;EAChB,UAAA,GAASC,mBAAAA,mBAAAA,CAAmB,MAAM,OAAO,IAAI;GAC3C,iBAAA;GACA,eAAe;IACb,MAAMJ,mBAAAA,2BAA2B,KAAK;IACtC,KAAA;GACF;GACA,aAAA;GACA,wBAAwB,WAAW,6BAA6B,OAAO;EACzE,CAAC;CACH,CAAC,CACL;CACA,MAAM,oBAAA,GAAmBK,uBAAAA,0BAAAA,CAA0B,QAAQ,GAAG;CAC9D,MAAM,kBAAkB,QAAQ;CAChC,MAAM,kBAAA,GAAiBC,0BAAAA,6BAAAA,CAA6B;EAClD,kBAAkB,gBAAgB;EAClC,QAAQ,gBAAgB;CAC1B,CAAC;CAED,MAAM,QAAQ,YAAY,YAAYC,mBAAAA,iBAAiB,SAAS;CAChE,MAAM,WAAA,GAAUC,0BAAAA,4BAAAA,CAA4B;EAC1C,GAAG;EACH,wBAAwB;EACxB,yBAAyB,gBAAgB,2BAA2B;CACtE,CAAC;CAED,QAAA,GAAOC,mBAAAA,WAAAA,CAAW;EAChB,KAAK,EAAA,GAACC,0BAAAA,yBAAAA,CAAyB,cAAc,CAAC;EAC9C,UAAU;GACR,MAAMC,mBAAAA,iBAAiB;GACvB,WAAW,iBAAiB;GAC5B,SAAS,iBAAiB;EAC5B;EACA,MAAM,YAAY,QAAQ;EAC1B,eAAe;EACf,WAAW,QAAQ,QAAQ,YAAY,KAAA;EACvC,QAAQ,iBAAiB;EACzB;CACF,CAAC;AACH"}
package/dist/index.d.cts CHANGED
@@ -1,27 +1,28 @@
1
- import { Lane } from "@runlane/contracts";
2
- import { PostgresStorageOptions } from "@runlane/postgres-storage";
3
- import { SqsTransportOptions } from "@runlane/transport-sqs";
1
+ import { TransportLane } from "@runlane/contracts";
2
+ import { PostgresStorageDriverOptions } from "@runlane/postgres-storage";
3
+ import { SqsLambdaHandler, SqsTransportOptions } from "@runlane/transport-sqs";
4
4
  import * as z from "zod";
5
-
6
- //#region src/postgres-sqs-lane.d.ts
7
5
  declare const postgresSqsLaneOptionsSchema: z.ZodObject<{
6
+ runHints: z.ZodOptional<z.ZodBoolean>;
8
7
  name: z.ZodOptional<z.ZodString>;
9
- postgres: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
8
+ postgres: z.ZodObject<{
9
+ runSignalNotifications: z.ZodOptional<z.ZodNever>;
10
+ }, z.core.$loose>;
10
11
  sqs: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
11
12
  }, z.core.$strict>;
12
13
  /**
13
14
  * Construction options for the first-party production Postgres/SQS lane.
14
15
  *
16
+ * runHints defaults to true; set false for serverless consumers to avoid a dedicated connection.
15
17
  * Postgres and SQS nested options are validated by their owning adapter packages.
16
18
  */
17
19
  type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {
18
- readonly postgres: PostgresStorageOptions;
20
+ readonly postgres: Omit<PostgresStorageDriverOptions, 'runSignalNotifications'>;
19
21
  readonly sqs: SqsTransportOptions;
20
22
  };
21
23
  /**
22
24
  * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.
23
25
  */
24
- declare function postgresSqsLane(options: PostgresSqsLaneOptions): Lane;
25
- //#endregion
26
- export { type PostgresSqsLaneOptions, postgresSqsLane };
26
+ export declare function postgresSqsLane(options: PostgresSqsLaneOptions): TransportLane<SqsLambdaHandler>;
27
+ export type { PostgresSqsLaneOptions };
27
28
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/postgres-sqs-lane.ts"],"mappings":";;;;;;cAmBM,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;;;;;;;KAetB,sBAAA,GAAyB,IAAA,CAAK,CAAA,CAAE,MAAA,QAAc,4BAAA;EAAA,SAC/C,QAAA,EAAU,sBAAA;EAAA,SACV,GAAA,EAAK,mBAAA;AAAA;;;;iBAMA,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,IAAI"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/postgres-sqs-lane.ts"],"mappings":";;;;cAyBM,8BAA4B,EAAA;;;;;;;GAUhC,EAAA,KAAA;;;;;;;KAQU,yBAAyB,KAAK,EAAE,cAAc;WAC/C,UAAU,KAAK;WACf,KAAK;;;;;wBAMA,gBAAgB,SAAS,yBAAyB,cAAc"}
package/dist/index.d.mts CHANGED
@@ -1,27 +1,28 @@
1
- import { Lane } from "@runlane/contracts";
2
- import { PostgresStorageOptions } from "@runlane/postgres-storage";
3
- import { SqsTransportOptions } from "@runlane/transport-sqs";
1
+ import { TransportLane } from "@runlane/contracts";
2
+ import { PostgresStorageDriverOptions } from "@runlane/postgres-storage";
3
+ import { SqsLambdaHandler, SqsTransportOptions } from "@runlane/transport-sqs";
4
4
  import * as z from "zod";
5
-
6
- //#region src/postgres-sqs-lane.d.ts
7
5
  declare const postgresSqsLaneOptionsSchema: z.ZodObject<{
6
+ runHints: z.ZodOptional<z.ZodBoolean>;
8
7
  name: z.ZodOptional<z.ZodString>;
9
- postgres: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
8
+ postgres: z.ZodObject<{
9
+ runSignalNotifications: z.ZodOptional<z.ZodNever>;
10
+ }, z.core.$loose>;
10
11
  sqs: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
11
12
  }, z.core.$strict>;
12
13
  /**
13
14
  * Construction options for the first-party production Postgres/SQS lane.
14
15
  *
16
+ * runHints defaults to true; set false for serverless consumers to avoid a dedicated connection.
15
17
  * Postgres and SQS nested options are validated by their owning adapter packages.
16
18
  */
17
19
  type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {
18
- readonly postgres: PostgresStorageOptions;
20
+ readonly postgres: Omit<PostgresStorageDriverOptions, 'runSignalNotifications'>;
19
21
  readonly sqs: SqsTransportOptions;
20
22
  };
21
23
  /**
22
24
  * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.
23
25
  */
24
- declare function postgresSqsLane(options: PostgresSqsLaneOptions): Lane;
25
- //#endregion
26
- export { type PostgresSqsLaneOptions, postgresSqsLane };
26
+ export declare function postgresSqsLane(options: PostgresSqsLaneOptions): TransportLane<SqsLambdaHandler>;
27
+ export type { PostgresSqsLaneOptions };
27
28
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/postgres-sqs-lane.ts"],"mappings":";;;;;;cAmBM,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;;;;;;;KAetB,sBAAA,GAAyB,IAAA,CAAK,CAAA,CAAE,MAAA,QAAc,4BAAA;EAAA,SAC/C,QAAA,EAAU,sBAAA;EAAA,SACV,GAAA,EAAK,mBAAA;AAAA;;;;iBAMA,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,IAAI"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/postgres-sqs-lane.ts"],"mappings":";;;;cAyBM,8BAA4B,EAAA;;;;;;;GAUhC,EAAA,KAAA;;;;;;;KAQU,yBAAyB,KAAK,EAAE,cAAc;WAC/C,UAAU,KAAK;WACf,KAAK;;;;;wBAMA,gBAAgB,SAAS,yBAAyB,cAAc"}
package/dist/index.mjs CHANGED
@@ -1,14 +1,18 @@
1
- import { ErrorCode, LaneDeliveryMode, RunlaneError, contractValidationMessages, createLane } from "@runlane/contracts";
2
- import { postgresStorage } from "@runlane/postgres-storage";
3
- import { sqsTransport } from "@runlane/transport-sqs";
1
+ import { ErrorCode, LaneDeliveryMode, RunlaneError, contractDefaults, contractValidationMessages, createLane } from "@runlane/contracts";
2
+ import { createPostgresCliAdapter, createPostgresStorageDriver, resolvePostgresStorageConfig } from "@runlane/postgres-storage";
3
+ import { createSqsDeliveryProvider } from "@runlane/transport-sqs";
4
4
  import { getZodIssueMessage, parseZodOrThrow } from "@runlane/utilities";
5
5
  import * as z from "zod";
6
- //#region src/postgres-sqs-lane.ts
6
+ // src/postgres-sqs-lane.ts
7
7
  const postgresSqsLaneOptionsSchema = z.strictObject({
8
+ runHints: z.boolean("runHints must be a boolean.").optional(),
8
9
  name: z.string(contractValidationMessages.lane.name).min(1, contractValidationMessages.lane.name).optional(),
9
- postgres: z.unknown().refine((postgresOptions) => postgresOptions !== void 0, { message: "Postgres SQS lane postgres options are required." }),
10
+ postgres: z.looseObject({ runSignalNotifications: z.never("Use runHints on a Postgres SQS lane.").optional() }, "Postgres SQS lane postgres options are required."),
10
11
  sqs: z.unknown().refine((sqsOptions) => sqsOptions !== void 0, { message: "Postgres SQS lane sqs options are required." })
11
12
  });
13
+ /**
14
+ * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.
15
+ */
12
16
  function postgresSqsLane(options) {
13
17
  const laneOptions = parseZodOrThrow(postgresSqsLaneOptionsSchema, options, (error) => new RunlaneError({
14
18
  code: ErrorCode.ConfigurationInvalid,
@@ -16,26 +20,38 @@ function postgresSqsLane(options) {
16
20
  fallbackMessage: "Postgres SQS lane options must be an object.",
17
21
  fieldMessages: {
18
22
  name: contractValidationMessages.lane.name,
19
- postgres: "Postgres SQS lane postgres options are required.",
20
23
  sqs: "Postgres SQS lane sqs options are required."
21
24
  },
22
25
  rootMessage: "Postgres SQS lane options must be an object.",
23
26
  unsupportedKeyMessage: (option) => `Postgres SQS lane option "${option}" is not supported.`
24
27
  })
25
28
  }));
26
- const transport = sqsTransport(laneOptions.sqs);
27
- const storage = postgresStorage(laneOptions.postgres);
29
+ const deliveryProvider = createSqsDeliveryProvider(options.sqs);
30
+ const postgresOptions = options.postgres;
31
+ const postgresConfig = resolvePostgresStorageConfig({
32
+ connectionString: postgresOptions.connectionString,
33
+ schema: postgresOptions.schema
34
+ });
35
+ const hints = laneOptions.runHints ?? contractDefaults.realtime.runHints;
36
+ const storage = createPostgresStorageDriver({
37
+ ...postgresOptions,
38
+ runSignalNotifications: hints,
39
+ workSignalNotifications: postgresOptions.workSignalNotifications ?? false
40
+ });
28
41
  return createLane({
42
+ cli: [createPostgresCliAdapter(postgresConfig)],
29
43
  delivery: {
30
44
  mode: LaneDeliveryMode.Transport,
31
- transport
45
+ publisher: deliveryProvider.publisher,
46
+ surface: deliveryProvider.surface
32
47
  },
33
48
  name: laneOptions.name ?? "postgres-sqs",
34
- productionDurable: true,
49
+ operatorReads: storage,
50
+ runSignal: hints ? storage.runSignal : void 0,
51
+ queues: deliveryProvider.queues,
35
52
  storage
36
53
  });
37
54
  }
38
- //#endregion
39
55
  export { postgresSqsLane };
40
56
 
41
57
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/postgres-sqs-lane.ts"],"sourcesContent":["import {\n contractValidationMessages,\n createLane,\n ErrorCode,\n LaneDeliveryMode,\n RunlaneError,\n type Lane,\n} from '@runlane/contracts'\nimport { postgresStorage, type PostgresStorageOptions } from '@runlane/postgres-storage'\nimport { sqsTransport, type SqsTransportOptions } from '@runlane/transport-sqs'\nimport { getZodIssueMessage, parseZodOrThrow } from '@runlane/utilities'\nimport * as z from 'zod'\n\nenum PostgresSqsLaneValidationMessage {\n OptionsObject = 'Postgres SQS lane options must be an object.',\n PostgresRequired = 'Postgres SQS lane postgres options are required.',\n SqsRequired = 'Postgres SQS lane sqs options are required.',\n}\n\nconst postgresSqsLaneOptionsSchema = z.strictObject({\n name: z.string(contractValidationMessages.lane.name).min(1, contractValidationMessages.lane.name).optional(),\n postgres: z.unknown().refine((postgresOptions) => postgresOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.PostgresRequired,\n }),\n sqs: z.unknown().refine((sqsOptions) => sqsOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.SqsRequired,\n }),\n})\n\n/**\n * Construction options for the first-party production Postgres/SQS lane.\n *\n * Postgres and SQS nested options are validated by their owning adapter packages.\n */\nexport type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {\n readonly postgres: PostgresStorageOptions\n readonly sqs: SqsTransportOptions\n}\n\n/**\n * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.\n */\nexport function postgresSqsLane(options: PostgresSqsLaneOptions): Lane\nexport function postgresSqsLane(options: unknown): Lane {\n const laneOptions = parseZodOrThrow(\n postgresSqsLaneOptionsSchema,\n options,\n (error) =>\n new RunlaneError({\n code: ErrorCode.ConfigurationInvalid,\n message: getZodIssueMessage(error.issues[0], {\n fallbackMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n fieldMessages: {\n name: contractValidationMessages.lane.name,\n postgres: PostgresSqsLaneValidationMessage.PostgresRequired,\n sqs: PostgresSqsLaneValidationMessage.SqsRequired,\n },\n rootMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n unsupportedKeyMessage: (option) => `Postgres SQS lane option \"${option}\" is not supported.`,\n }),\n }),\n )\n const transport = sqsTransport(laneOptions.sqs as SqsTransportOptions)\n const storage = postgresStorage(laneOptions.postgres as PostgresStorageOptions)\n\n return createLane({\n delivery: { mode: LaneDeliveryMode.Transport, transport },\n name: laneOptions.name ?? 'postgres-sqs',\n productionDurable: true,\n storage,\n })\n}\n"],"mappings":";;;;;;AAmBA,MAAM,+BAA+B,EAAE,aAAa;CAClD,MAAM,EAAE,OAAO,2BAA2B,KAAK,IAAI,EAAE,IAAI,GAAG,2BAA2B,KAAK,IAAI,EAAE,SAAS;CAC3G,UAAU,EAAE,QAAQ,EAAE,QAAQ,oBAAoB,oBAAoB,KAAA,GAAW,EAC/E,SAAA,mDACF,CAAC;CACD,KAAK,EAAE,QAAQ,EAAE,QAAQ,eAAe,eAAe,KAAA,GAAW,EAChE,SAAA,8CACF,CAAC;AACH,CAAC;AAgBD,SAAgB,gBAAgB,SAAwB;CACtD,MAAM,cAAc,gBAClB,8BACA,UACC,UACC,IAAI,aAAa;EACf,MAAM,UAAU;EAChB,SAAS,mBAAmB,MAAM,OAAO,IAAI;GAC3C,iBAAA;GACA,eAAe;IACb,MAAM,2BAA2B,KAAK;IACtC,UAAA;IACA,KAAA;GACF;GACA,aAAA;GACA,wBAAwB,WAAW,6BAA6B,OAAO;EACzE,CAAC;CACH,CAAC,CACL;CACA,MAAM,YAAY,aAAa,YAAY,GAA0B;CACrE,MAAM,UAAU,gBAAgB,YAAY,QAAkC;CAE9E,OAAO,WAAW;EAChB,UAAU;GAAE,MAAM,iBAAiB;GAAW;EAAU;EACxD,MAAM,YAAY,QAAQ;EAC1B,mBAAmB;EACnB;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/postgres-sqs-lane.ts"],"sourcesContent":["import {\n contractDefaults,\n contractValidationMessages,\n createLane,\n ErrorCode,\n LaneDeliveryMode,\n RunlaneError,\n type TransportLane,\n} from '@runlane/contracts'\nimport {\n createPostgresCliAdapter,\n createPostgresStorageDriver,\n resolvePostgresStorageConfig,\n type PostgresStorageDriverOptions,\n} from '@runlane/postgres-storage'\nimport { createSqsDeliveryProvider, type SqsLambdaHandler, type SqsTransportOptions } from '@runlane/transport-sqs'\nimport { getZodIssueMessage, parseZodOrThrow } from '@runlane/utilities'\nimport * as z from 'zod'\n\nenum PostgresSqsLaneValidationMessage {\n OptionsObject = 'Postgres SQS lane options must be an object.',\n PostgresRequired = 'Postgres SQS lane postgres options are required.',\n SqsRequired = 'Postgres SQS lane sqs options are required.',\n}\n\nconst postgresSqsLaneOptionsSchema = z.strictObject({\n runHints: z.boolean('runHints must be a boolean.').optional(),\n name: z.string(contractValidationMessages.lane.name).min(1, contractValidationMessages.lane.name).optional(),\n postgres: z.looseObject(\n { runSignalNotifications: z.never('Use runHints on a Postgres SQS lane.').optional() },\n PostgresSqsLaneValidationMessage.PostgresRequired,\n ),\n sqs: z.unknown().refine((sqsOptions) => sqsOptions !== undefined, {\n message: PostgresSqsLaneValidationMessage.SqsRequired,\n }),\n})\n\n/**\n * Construction options for the first-party production Postgres/SQS lane.\n *\n * runHints defaults to true; set false for serverless consumers to avoid a dedicated connection.\n * Postgres and SQS nested options are validated by their owning adapter packages.\n */\nexport type PostgresSqsLaneOptions = Omit<z.output<typeof postgresSqsLaneOptionsSchema>, 'postgres' | 'sqs'> & {\n readonly postgres: Omit<PostgresStorageDriverOptions, 'runSignalNotifications'>\n readonly sqs: SqsTransportOptions\n}\n\n/**\n * Creates the first-party production lane backed by Postgres storage and SQS wakeup delivery.\n */\nexport function postgresSqsLane(options: PostgresSqsLaneOptions): TransportLane<SqsLambdaHandler> {\n const laneOptions = parseZodOrThrow(\n postgresSqsLaneOptionsSchema,\n options,\n (error) =>\n new RunlaneError({\n code: ErrorCode.ConfigurationInvalid,\n message: getZodIssueMessage(error.issues[0], {\n fallbackMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n fieldMessages: {\n name: contractValidationMessages.lane.name,\n sqs: PostgresSqsLaneValidationMessage.SqsRequired,\n },\n rootMessage: PostgresSqsLaneValidationMessage.OptionsObject,\n unsupportedKeyMessage: (option) => `Postgres SQS lane option \"${option}\" is not supported.`,\n }),\n }),\n )\n const deliveryProvider = createSqsDeliveryProvider(options.sqs)\n const postgresOptions = options.postgres\n const postgresConfig = resolvePostgresStorageConfig({\n connectionString: postgresOptions.connectionString,\n schema: postgresOptions.schema,\n })\n // Nothing on this lane listens for PostgreSQL work signals; SQS carries every wakeup.\n const hints = laneOptions.runHints ?? contractDefaults.realtime.runHints\n const storage = createPostgresStorageDriver({\n ...postgresOptions,\n runSignalNotifications: hints,\n workSignalNotifications: postgresOptions.workSignalNotifications ?? false,\n })\n\n return createLane({\n cli: [createPostgresCliAdapter(postgresConfig)],\n delivery: {\n mode: LaneDeliveryMode.Transport,\n publisher: deliveryProvider.publisher,\n surface: deliveryProvider.surface,\n },\n name: laneOptions.name ?? 'postgres-sqs',\n operatorReads: storage,\n runSignal: hints ? storage.runSignal : undefined,\n queues: deliveryProvider.queues,\n storage,\n })\n}\n"],"mappings":";;;;;;AAyBA,MAAM,+BAA+B,EAAE,aAAa;CAClD,UAAU,EAAE,QAAQ,6BAA6B,CAAC,CAAC,SAAS;CAC5D,MAAM,EAAE,OAAO,2BAA2B,KAAK,IAAI,CAAC,CAAC,IAAI,GAAG,2BAA2B,KAAK,IAAI,CAAC,CAAC,SAAS;CAC3G,UAAU,EAAE,YACV,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC,CAAC,SAAS,EAAE,GAAA,kDAEvF;CACA,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,eAAe,eAAe,KAAA,GAAW,EAChE,SAAA,8CACF,CAAC;AACH,CAAC;;;;AAgBD,SAAgB,gBAAgB,SAAkE;CAChG,MAAM,cAAc,gBAClB,8BACA,UACC,UACC,IAAI,aAAa;EACf,MAAM,UAAU;EAChB,SAAS,mBAAmB,MAAM,OAAO,IAAI;GAC3C,iBAAA;GACA,eAAe;IACb,MAAM,2BAA2B,KAAK;IACtC,KAAA;GACF;GACA,aAAA;GACA,wBAAwB,WAAW,6BAA6B,OAAO;EACzE,CAAC;CACH,CAAC,CACL;CACA,MAAM,mBAAmB,0BAA0B,QAAQ,GAAG;CAC9D,MAAM,kBAAkB,QAAQ;CAChC,MAAM,iBAAiB,6BAA6B;EAClD,kBAAkB,gBAAgB;EAClC,QAAQ,gBAAgB;CAC1B,CAAC;CAED,MAAM,QAAQ,YAAY,YAAY,iBAAiB,SAAS;CAChE,MAAM,UAAU,4BAA4B;EAC1C,GAAG;EACH,wBAAwB;EACxB,yBAAyB,gBAAgB,2BAA2B;CACtE,CAAC;CAED,OAAO,WAAW;EAChB,KAAK,CAAC,yBAAyB,cAAc,CAAC;EAC9C,UAAU;GACR,MAAM,iBAAiB;GACvB,WAAW,iBAAiB;GAC5B,SAAS,iBAAiB;EAC5B;EACA,MAAM,YAAY,QAAQ;EAC1B,eAAe;EACf,WAAW,QAAQ,QAAQ,YAAY,KAAA;EACvC,QAAQ,iBAAiB;EACzB;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runlane/lane-postgres-sqs",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Production-ready Runlane lane composing PostgreSQL storage with Amazon SQS transport.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,11 +48,11 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "zod": "^4.3.6",
52
- "@runlane/contracts": "0.3.0",
53
- "@runlane/postgres-storage": "0.3.0",
54
- "@runlane/transport-sqs": "0.3.0",
55
- "@runlane/utilities": "0.3.0"
51
+ "zod": "^4.5.4",
52
+ "@runlane/contracts": "0.5.0",
53
+ "@runlane/postgres-storage": "0.5.0",
54
+ "@runlane/transport-sqs": "0.5.0",
55
+ "@runlane/utilities": "0.5.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@aws-sdk/client-sqs": "^3.1045.0",
@@ -60,17 +60,20 @@
60
60
  "pg": "^8.20.0",
61
61
  "tsx": "^4.21.0",
62
62
  "@repo/eslint": "0.0.0",
63
- "@repo/postgres-test-runner": "0.0.3",
64
63
  "@repo/tsdown": "0.0.0",
65
64
  "@repo/typescript": "0.0.0",
66
65
  "@repo/vitest": "0.0.0",
67
- "@runlane/core": "0.3.0",
68
- "@runlane/testing": "0.3.0"
66
+ "@runlane/core": "0.5.0",
67
+ "@runlane/lane-postgres-polling": "0.5.0",
68
+ "@runlane/testing": "0.5.0"
69
69
  },
70
70
  "scripts": {
71
+ "bench:counters": "tsx --tsconfig ../../tooling/typescript/workspace-source.json scripts/fixed-workload-counters.ts",
71
72
  "build": "tsdown",
72
73
  "clean": "rimraf dist",
73
74
  "lint": "eslint --max-warnings 0",
75
+ "stress": "tsx --tsconfig ../../tooling/typescript/workspace-source.json scripts/run-stress.ts",
76
+ "stress:local": "tsx --tsconfig ../../tooling/typescript/workspace-source.json scripts/stress-local.ts",
74
77
  "typecheck": "tsc --noEmit",
75
78
  "test": "vitest run",
76
79
  "test:postgres:local": "tsx --tsconfig ../../tooling/typescript/workspace-source.json scripts/test-postgres-local.ts",