@runlane/lane-postgres-sqs 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,21 +16,21 @@ 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
36
  /**
@@ -43,7 +43,6 @@ function postgresSqsLane(options) {
43
43
  fallbackMessage: "Postgres SQS lane options must be an object.",
44
44
  fieldMessages: {
45
45
  name: _runlane_contracts.contractValidationMessages.lane.name,
46
- postgres: "Postgres SQS lane postgres options are required.",
47
46
  sqs: "Postgres SQS lane sqs options are required."
48
47
  },
49
48
  rootMessage: "Postgres SQS lane options must be an object.",
@@ -56,7 +55,12 @@ function postgresSqsLane(options) {
56
55
  connectionString: postgresOptions.connectionString,
57
56
  schema: postgresOptions.schema
58
57
  });
59
- const storage = (0, _runlane_postgres_storage.createPostgresStorageDriver)(postgresOptions);
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
+ });
60
64
  return (0, _runlane_contracts.createLane)({
61
65
  cli: [(0, _runlane_postgres_storage.createPostgresCliAdapter)(postgresConfig)],
62
66
  delivery: {
@@ -66,11 +70,11 @@ function postgresSqsLane(options) {
66
70
  },
67
71
  name: laneOptions.name ?? "postgres-sqs",
68
72
  operatorReads: storage,
73
+ runSignal: hints ? storage.runSignal : void 0,
69
74
  queues: deliveryProvider.queues,
70
75
  storage
71
76
  });
72
77
  }
73
- //#endregion
74
78
  exports.postgresSqsLane = postgresSqsLane;
75
79
 
76
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 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 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: PostgresStorageDriverOptions\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 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 deliveryProvider = createSqsDeliveryProvider(options.sqs)\n const postgresOptions = options.postgres\n const postgresConfig = resolvePostgresStorageConfig({\n connectionString: postgresOptions.connectionString,\n schema: postgresOptions.schema,\n })\n const storage = createPostgresStorageDriver(postgresOptions)\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 queues: deliveryProvider.queues,\n storage,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,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;;;;AAeD,SAAgB,gBAAgB,SAAkE;CAChG,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,oBAAA,GAAA,uBAAA,2BAA6C,QAAQ,GAAG;CAC9D,MAAM,kBAAkB,QAAQ;CAChC,MAAM,kBAAA,GAAA,0BAAA,8BAA8C;EAClD,kBAAkB,gBAAgB;EAClC,QAAQ,gBAAgB;CAC1B,CAAC;CACD,MAAM,WAAA,GAAA,0BAAA,6BAAsC,eAAe;CAE3D,QAAA,GAAA,mBAAA,YAAkB;EAChB,KAAK,EAAA,GAAA,0BAAA,0BAA0B,cAAc,CAAC;EAC9C,UAAU;GACR,MAAMG,mBAAAA,iBAAiB;GACvB,WAAW,iBAAiB;GAC5B,SAAS,iBAAiB;EAC5B;EACA,MAAM,YAAY,QAAQ;EAC1B,eAAe;EACf,QAAQ,iBAAiB;EACzB;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
@@ -2,26 +2,27 @@ import { TransportLane } from "@runlane/contracts";
2
2
  import { PostgresStorageDriverOptions } from "@runlane/postgres-storage";
3
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: PostgresStorageDriverOptions;
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): TransportLane<SqsLambdaHandler>;
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":";;;;;;cAwBM,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;;;;;;;KAetB,sBAAA,GAAyB,IAAA,CAAK,CAAA,CAAE,MAAA,QAAc,4BAAA;EAAA,SAC/C,QAAA,EAAU,4BAAA;EAAA,SACV,GAAA,EAAK,mBAAA;AAAA;;;;iBAMA,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,aAAA,CAAc,gBAAA"}
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
@@ -2,26 +2,27 @@ import { TransportLane } from "@runlane/contracts";
2
2
  import { PostgresStorageDriverOptions } from "@runlane/postgres-storage";
3
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: PostgresStorageDriverOptions;
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): TransportLane<SqsLambdaHandler>;
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":";;;;;;cAwBM,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;;;;;;;KAetB,sBAAA,GAAyB,IAAA,CAAK,CAAA,CAAE,MAAA,QAAc,4BAAA;EAAA,SAC/C,QAAA,EAAU,4BAAA;EAAA,SACV,GAAA,EAAK,mBAAA;AAAA;;;;iBAMA,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,aAAA,CAAc,gBAAA"}
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,12 +1,13 @@
1
- import { ErrorCode, LaneDeliveryMode, RunlaneError, contractValidationMessages, createLane } from "@runlane/contracts";
1
+ import { ErrorCode, LaneDeliveryMode, RunlaneError, contractDefaults, contractValidationMessages, createLane } from "@runlane/contracts";
2
2
  import { createPostgresCliAdapter, createPostgresStorageDriver, resolvePostgresStorageConfig } from "@runlane/postgres-storage";
3
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
  });
12
13
  /**
@@ -19,7 +20,6 @@ function postgresSqsLane(options) {
19
20
  fallbackMessage: "Postgres SQS lane options must be an object.",
20
21
  fieldMessages: {
21
22
  name: contractValidationMessages.lane.name,
22
- postgres: "Postgres SQS lane postgres options are required.",
23
23
  sqs: "Postgres SQS lane sqs options are required."
24
24
  },
25
25
  rootMessage: "Postgres SQS lane options must be an object.",
@@ -32,7 +32,12 @@ function postgresSqsLane(options) {
32
32
  connectionString: postgresOptions.connectionString,
33
33
  schema: postgresOptions.schema
34
34
  });
35
- const storage = createPostgresStorageDriver(postgresOptions);
35
+ const hints = laneOptions.runHints ?? contractDefaults.realtime.runHints;
36
+ const storage = createPostgresStorageDriver({
37
+ ...postgresOptions,
38
+ runSignalNotifications: hints,
39
+ workSignalNotifications: postgresOptions.workSignalNotifications ?? false
40
+ });
36
41
  return createLane({
37
42
  cli: [createPostgresCliAdapter(postgresConfig)],
38
43
  delivery: {
@@ -42,11 +47,11 @@ function postgresSqsLane(options) {
42
47
  },
43
48
  name: laneOptions.name ?? "postgres-sqs",
44
49
  operatorReads: storage,
50
+ runSignal: hints ? storage.runSignal : void 0,
45
51
  queues: deliveryProvider.queues,
46
52
  storage
47
53
  });
48
54
  }
49
- //#endregion
50
55
  export { postgresSqsLane };
51
56
 
52
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 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 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: PostgresStorageDriverOptions\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 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 deliveryProvider = createSqsDeliveryProvider(options.sqs)\n const postgresOptions = options.postgres\n const postgresConfig = resolvePostgresStorageConfig({\n connectionString: postgresOptions.connectionString,\n schema: postgresOptions.schema,\n })\n const storage = createPostgresStorageDriver(postgresOptions)\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 queues: deliveryProvider.queues,\n storage,\n })\n}\n"],"mappings":";;;;;;AAwBA,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;;;;AAeD,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,UAAA;IACA,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;CACD,MAAM,UAAU,4BAA4B,eAAe;CAE3D,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,QAAQ,iBAAiB;EACzB;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.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Production-ready Runlane lane composing PostgreSQL storage with Amazon SQS transport.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -49,10 +49,10 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "zod": "^4.5.4",
52
- "@runlane/contracts": "0.4.0",
53
- "@runlane/postgres-storage": "0.4.0",
54
- "@runlane/transport-sqs": "0.4.0",
55
- "@runlane/utilities": "0.4.0"
52
+ "@runlane/contracts": "0.5.1",
53
+ "@runlane/postgres-storage": "0.5.1",
54
+ "@runlane/transport-sqs": "0.5.1",
55
+ "@runlane/utilities": "0.5.1"
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.4",
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.4.0",
68
- "@runlane/testing": "0.4.0"
66
+ "@runlane/core": "0.5.1",
67
+ "@runlane/lane-postgres-polling": "0.5.1",
68
+ "@runlane/testing": "0.5.1"
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",