@ontemper/sdk 0.7.1-postgresql.1 → 0.7.1-postgresql.3

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 (79) hide show
  1. package/README.md +50 -6
  2. package/dist/As2Resource.d.ts +431 -76
  3. package/dist/As2Resource.d.ts.map +1 -1
  4. package/dist/As2Resource.js +31 -30
  5. package/dist/As2Resource.js.map +1 -1
  6. package/dist/As2Transport.d.ts.map +1 -1
  7. package/dist/As2Transport.js +3 -1
  8. package/dist/As2Transport.js.map +1 -1
  9. package/dist/As2Wire.d.ts +39 -0
  10. package/dist/As2Wire.d.ts.map +1 -1
  11. package/dist/DatabaseTunnelAuthorization.d.ts +11 -0
  12. package/dist/DatabaseTunnelAuthorization.d.ts.map +1 -0
  13. package/dist/DatabaseTunnelAuthorization.js +35 -0
  14. package/dist/DatabaseTunnelAuthorization.js.map +1 -0
  15. package/dist/ExpiringMap.d.ts +21 -0
  16. package/dist/ExpiringMap.d.ts.map +1 -0
  17. package/dist/ExpiringMap.js +79 -0
  18. package/dist/ExpiringMap.js.map +1 -0
  19. package/dist/HttpApiResource.d.ts +2904 -177
  20. package/dist/HttpApiResource.d.ts.map +1 -1
  21. package/dist/HttpApiResource.js +81 -59
  22. package/dist/HttpApiResource.js.map +1 -1
  23. package/dist/Kafka.d.ts +89 -0
  24. package/dist/Kafka.d.ts.map +1 -0
  25. package/dist/Kafka.js +297 -0
  26. package/dist/Kafka.js.map +1 -0
  27. package/dist/Manifest.d.ts +1 -1
  28. package/dist/Manifest.js +1 -1
  29. package/dist/PostgreSql.d.ts +2 -2
  30. package/dist/PostgreSql.d.ts.map +1 -1
  31. package/dist/PostgreSql.js +4 -13
  32. package/dist/PostgreSql.js.map +1 -1
  33. package/dist/PostgreSqlPool.d.ts +2 -40
  34. package/dist/PostgreSqlPool.d.ts.map +1 -1
  35. package/dist/PostgreSqlPool.js +13 -26
  36. package/dist/PostgreSqlPool.js.map +1 -1
  37. package/dist/PostgreSqlTimeouts.d.ts +4 -2
  38. package/dist/PostgreSqlTimeouts.d.ts.map +1 -1
  39. package/dist/PostgreSqlTimeouts.js +5 -4
  40. package/dist/PostgreSqlTimeouts.js.map +1 -1
  41. package/dist/Redaction.d.ts +2 -0
  42. package/dist/Redaction.d.ts.map +1 -1
  43. package/dist/Redaction.js +16 -4
  44. package/dist/Redaction.js.map +1 -1
  45. package/dist/ResourceRecords.d.ts +1086 -0
  46. package/dist/ResourceRecords.d.ts.map +1 -0
  47. package/dist/ResourceRecords.js +303 -0
  48. package/dist/ResourceRecords.js.map +1 -0
  49. package/dist/Resources.d.ts +17 -0
  50. package/dist/Resources.d.ts.map +1 -0
  51. package/dist/Resources.js +15 -0
  52. package/dist/Resources.js.map +1 -0
  53. package/dist/ResourcesCache.d.ts +33 -0
  54. package/dist/ResourcesCache.d.ts.map +1 -0
  55. package/dist/ResourcesCache.js +205 -0
  56. package/dist/ResourcesCache.js.map +1 -0
  57. package/dist/ResourcesEnv.d.ts +81 -0
  58. package/dist/ResourcesEnv.d.ts.map +1 -0
  59. package/dist/ResourcesEnv.js +104 -0
  60. package/dist/ResourcesEnv.js.map +1 -0
  61. package/dist/ResourcesErrors.d.ts +5 -1
  62. package/dist/ResourcesErrors.d.ts.map +1 -1
  63. package/dist/ResourcesErrors.js +5 -2
  64. package/dist/ResourcesErrors.js.map +1 -1
  65. package/dist/ResourcesToken.d.ts +9 -0
  66. package/dist/ResourcesToken.d.ts.map +1 -1
  67. package/dist/ResourcesToken.js +20 -7
  68. package/dist/ResourcesToken.js.map +1 -1
  69. package/dist/RuntimeResources.d.ts +18 -3
  70. package/dist/RuntimeResources.d.ts.map +1 -1
  71. package/dist/RuntimeResources.js +54 -30
  72. package/dist/RuntimeResources.js.map +1 -1
  73. package/dist/TransportResource.d.ts +1 -32
  74. package/dist/TransportResource.d.ts.map +1 -1
  75. package/dist/TransportResource.js +1 -19
  76. package/dist/TransportResource.js.map +1 -1
  77. package/dist/Workflow.js +2 -2
  78. package/dist/Workflow.js.map +1 -1
  79. package/package.json +17 -5
package/README.md CHANGED
@@ -326,11 +326,11 @@ no crypto.
326
326
 
327
327
  ## PostgreSQL
328
328
 
329
- `@temper/workflow/postgresql` opens a `pg.Pool` for a PostgreSQL Resource by key. It loads `pg` and `ws`, which
330
- the workflow installs; no other entry point loads them. TypeScript code also needs `@types/pg`.
329
+ `@temper/workflow/resources` opens a `pg.Pool` for a PostgreSQL Resource by key. A pool loads `pg`, and a builder's
330
+ tunnel to a Temper-managed database loads `ws`, which the workflow installs; importing the entry point loads neither. TypeScript code also needs `@types/pg`.
331
331
 
332
332
  ```ts
333
- import { createPostgresqlPool, makePostgresqlPool } from '@temper/workflow/postgresql';
333
+ import { createPostgresqlPool, makePostgresqlPool } from '@temper/workflow/resources';
334
334
 
335
335
  // A script or a module-level pool; the caller ends it with `pool.end()`.
336
336
  const pool = await createPostgresqlPool('orders-db');
@@ -353,6 +353,49 @@ WebSocket tunnel. Each physical connection reads the current runtime token, and
353
353
  connection without a TCP fallback. `createPostgresqlPool` registers the password in the process-wide secret
354
354
  registry; inside a workflow handler, prefer `makePostgresqlPool`, which registers it in the workflow's own.
355
355
 
356
+ ## Resource records and Kafka
357
+
358
+ `@temper/workflow/resources` gives Effect workflows what `@ontemper/resources` gives legacy ones: record schemas
359
+ (`KafkaResource`, `S3Resource`, `AzureBlobResource`, `SftpResource`, `PostgresqlResource`), `kafkaConfig`, and a promise
360
+ `env` for code that cannot run an Effect. Declare the Resource with `Resource` from the root; its secrets arrive as
361
+ `Redacted` values, and `kafkaConfig` unwraps them itself. It loads the optional peers `@aws-sdk/credential-providers` and
362
+ `aws-msk-iam-sasl-signer-js` only for AWS MSK IAM.
363
+
364
+ ```ts
365
+ import { Resource } from '@temper/workflow';
366
+ import { KafkaResource, kafkaConfig } from '@temper/workflow/resources';
367
+ import { Kafka } from 'kafkajs';
368
+
369
+ class Events extends Resource<Events>()('events', { type: 'kafka', schema: KafkaResource }) {}
370
+
371
+ // In an Effect: const kafka = new Kafka(kafkaConfig(yield* Events));
372
+ ```
373
+
374
+ For scripts outside Effect, the subpath exports the promise-style `env`:
375
+
376
+ ```ts
377
+ import { env, S3Resource } from '@temper/workflow/resources';
378
+
379
+ const archive = await env.resources.resolve('archive', S3Resource);
380
+ const metadata = await env.resources.inspect('archive');
381
+ const { key } = await env.resources.select({ resourceTypeKey: 'http_api', match: { tenantKey } });
382
+ const region = await env.variables.get('PARTNER_REGION');
383
+ ```
384
+
385
+ Without a schema, `resolve` returns the JSON object; with one, it decodes it and keeps extension fields.
386
+ `ResourceNotFoundError` means the key or selection has no record. A found record with a missing reference
387
+ fails with `InvalidResourceError`; unknown closed values in a built-in schema fail with `UnknownRecordValueError`.
388
+ Authorization failures use `ResourcesUnauthorizedError`; outages use `ResourcesUnavailableError`.
389
+
390
+ Promise reads use the same runtime API and Run token as the declarations. Their cache matches the legacy
391
+ resolver: a 30 s TTL, up to 15 min of stale reads through an outage (5 min for selections), and a separate
392
+ 10 s select-miss cache with a cap of 60 distinct misses per minute. `{ cache: false }` bypasses it;
393
+ `{ ttlMs }` sets a read's TTL. The legacy cache environment settings still apply.
394
+
395
+ The runtime API cannot list Variables, so snapshot `initialize`, `reload`, `variables.tryGet`, and
396
+ `variables.has` have no equivalent. The legacy partners and connections APIs are also excluded.
397
+ Existing workflows can keep `@ontemper/resources`; this entry does not modify that package.
398
+
356
399
  ## Versions
357
400
 
358
401
  CI publishes every version to npm as `@ontemper/sdk`; nobody publishes by hand. Workflow code keeps
@@ -366,10 +409,11 @@ npm install --save-exact @temper/workflow@npm:@ontemper/sdk@<version>
366
409
  A published version never changes. The workflow template and the examples pin one exact
367
410
  version; `pnpm sdk:pin` moves them all together.
368
411
 
369
- The package has nine entry points: `@temper/workflow`, `@temper/workflow/testing`,
412
+ The package has ten entry points: `@temper/workflow`, `@temper/workflow/testing`,
370
413
  `@temper/workflow/contract`, `@temper/workflow/sftp`, `@temper/workflow/sftp/testing`,
371
- `@temper/workflow/edi`, `@temper/workflow/as2`, `@temper/workflow/as2/testing`, and `@temper/workflow/postgresql`.
372
- Only `/sftp` loads `ssh2`, and only `/postgresql` loads `pg` and `ws` (optional peer dependencies).
414
+ `@temper/workflow/edi`, `@temper/workflow/as2`, `@temper/workflow/as2/testing`, and `@temper/workflow/resources`.
415
+ Only `/sftp` loads `ssh2`. In `/resources`, only a PostgreSQL pool loads `pg` and `ws`, and only AWS MSK IAM loads
416
+ `@aws-sdk/credential-providers` and `aws-msk-iam-sasl-signer-js` (optional peer dependencies).
373
417
  `@temper/workflow/contract` holds the runtime Resources HttpApi and the
374
418
  manifest, trigger, and invocation schemas that the platform imports. Workflow code rarely needs it.
375
419