@smartcrab/contracts-management 0.8.0 → 0.9.0-next-20261204032426

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.
@@ -89,6 +89,7 @@ export const connectionGetResponseSchema = connectionSchema;
89
89
  // PATCH /connections/:connectionId
90
90
  // ---------------------------------------------------------------------------
91
91
  export const connectionUpdateRequestSchema = z.strictObject({
92
+ /** Reviewed row's `updated_at`; required for generic OIDC mutations unless `If-Match` is used. */
92
93
  expected_updated_at: z.iso
93
94
  .datetime()
94
95
  .optional()
package/dist/rbac.d.ts CHANGED
@@ -94,10 +94,9 @@ export declare const IMPERSONATION_FORBIDDEN_SCOPES: readonly ["user_identities:
94
94
  * billing/viewer, withheld from developer. The Developer table lists "Client,
95
95
  * Connection, Domain, Webhook" resources, with `introspect` as a standalone
96
96
  * OAuth capability for resource-server token validation. `dlq:read` is limited
97
- * to inspection; `dlq:write` is Owner/Admin-only because redrive covers every
98
- * source queue. Every other role either reads broadly (`viewer`, "読み取りのみ") or
99
- * needs the roster for its work (`admin` administers the workspace;
100
- * `support`/`billing` deal with the workspace's people and billing contacts day to day).
97
+ * to Owner/Admin/Developer, with Developer read-only; Viewer is excluded because
98
+ * DLQ records may include billing or audit data. `dlq:write` is Owner/Admin-only
99
+ * because redrive covers every source queue.
101
100
  */
102
101
  export declare const ROLE_SCOPES: Readonly<Record<WorkspaceRole, readonly ManagementScope[]>>;
103
102
  export declare const scopesForRole: (role: WorkspaceRole) => readonly ManagementScope[];
package/dist/rbac.js CHANGED
@@ -113,10 +113,9 @@ export const IMPERSONATION_FORBIDDEN_SCOPES = [
113
113
  * billing/viewer, withheld from developer. The Developer table lists "Client,
114
114
  * Connection, Domain, Webhook" resources, with `introspect` as a standalone
115
115
  * OAuth capability for resource-server token validation. `dlq:read` is limited
116
- * to inspection; `dlq:write` is Owner/Admin-only because redrive covers every
117
- * source queue. Every other role either reads broadly (`viewer`, "読み取りのみ") or
118
- * needs the roster for its work (`admin` administers the workspace;
119
- * `support`/`billing` deal with the workspace's people and billing contacts day to day).
116
+ * to Owner/Admin/Developer, with Developer read-only; Viewer is excluded because
117
+ * DLQ records may include billing or audit data. `dlq:write` is Owner/Admin-only
118
+ * because redrive covers every source queue.
120
119
  */
121
120
  export const ROLE_SCOPES = {
122
121
  owner: MANAGEMENT_SCOPES,
@@ -189,7 +188,6 @@ export const ROLE_SCOPES = {
189
188
  "user_sessions:read",
190
189
  "user_data_jobs:read",
191
190
  "webhooks:read",
192
- "dlq:read",
193
191
  "audit_events:read",
194
192
  "usage:read",
195
193
  "billing:read",
@@ -11,9 +11,9 @@ import { z } from "zod";
11
11
  * (private key, provider token, internal risk score).
12
12
  * - the async job lifecycle convention used elsewhere in the schema, e.g.
13
13
  * `email_deliveries.status` (§12.8) and `outbox_events.status` (§11.16).
14
- * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB) —
15
- * bulk import records and export output are therefore referenced by an R2
16
- * URL, never embedded inline in the job resource itself.
14
+ * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB):
15
+ * import source URLs are request-only capabilities, while export artifacts
16
+ * are accessed through their scoped download route; neither is embedded.
17
17
  *
18
18
  * Should a future design.md revision add explicit
19
19
  * `user_import_jobs`/`user_export_jobs` tables, this file's field set should
@@ -46,7 +46,6 @@ export declare const userImportJobSchema: z.ZodObject<{
46
46
  json: "json";
47
47
  csv: "csv";
48
48
  }>;
49
- source_url: z.ZodURL;
50
49
  total_records: z.ZodNullable<z.ZodNumber>;
51
50
  processed_records: z.ZodNumber;
52
51
  succeeded_records: z.ZodNumber;
@@ -86,7 +85,6 @@ export declare const userImportJobCreateResponseSchema: z.ZodObject<{
86
85
  json: "json";
87
86
  csv: "csv";
88
87
  }>;
89
- source_url: z.ZodURL;
90
88
  total_records: z.ZodNullable<z.ZodNumber>;
91
89
  processed_records: z.ZodNumber;
92
90
  succeeded_records: z.ZodNumber;
@@ -117,7 +115,6 @@ export declare const userImportJobGetResponseSchema: z.ZodObject<{
117
115
  json: "json";
118
116
  csv: "csv";
119
117
  }>;
120
- source_url: z.ZodURL;
121
118
  total_records: z.ZodNullable<z.ZodNumber>;
122
119
  processed_records: z.ZodNumber;
123
120
  succeeded_records: z.ZodNumber;
package/dist/user-jobs.js CHANGED
@@ -13,9 +13,9 @@ import { environmentIdSchema, jobIdSchema, userIdSchema } from "./primitives.js"
13
13
  * (private key, provider token, internal risk score).
14
14
  * - the async job lifecycle convention used elsewhere in the schema, e.g.
15
15
  * `email_deliveries.status` (§12.8) and `outbox_events.status` (§11.16).
16
- * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB) —
17
- * bulk import records and export output are therefore referenced by an R2
18
- * URL, never embedded inline in the job resource itself.
16
+ * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB):
17
+ * import source URLs are request-only capabilities, while export artifacts
18
+ * are accessed through their scoped download route; neither is embedded.
19
19
  *
20
20
  * Should a future design.md revision add explicit
21
21
  * `user_import_jobs`/`user_export_jobs` tables, this file's field set should
@@ -39,8 +39,6 @@ export const userImportJobSchema = z.strictObject({
39
39
  environment_id: environmentIdSchema,
40
40
  status: jobStatusSchema,
41
41
  format: userImportFormatSchema,
42
- /** Where the platform fetched the source records from (an R2/customer-hosted HTTPS URL). */
43
- source_url: httpsUrlSchema,
44
42
  total_records: z.number().int().nonnegative().nullable(),
45
43
  processed_records: z.number().int().nonnegative(),
46
44
  succeeded_records: z.number().int().nonnegative(),
@@ -55,6 +53,7 @@ export const userImportJobSchema = z.strictObject({
55
53
  export const userImportJobCreateRequestSchema = z.strictObject({
56
54
  environment_id: environmentIdSchema,
57
55
  format: userImportFormatSchema,
56
+ /** A transient fetch capability; never persisted or returned in job metadata. */
58
57
  source_url: httpsUrlSchema,
59
58
  });
60
59
  export const userImportJobCreateResponseSchema = userImportJobSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartcrab/contracts-management",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-next-20261204032426",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "zod": "4.6.7",
31
- "@smartcrab/contracts-public": "0.8.0"
31
+ "@smartcrab/contracts-public": "0.9.0-next-20261204032426"
32
32
  },
33
33
  "devDependencies": {
34
34
  "typescript": "5.9.3",
@@ -75,3 +75,14 @@ describe("connectionCreateRequestSchema / connectionCreateResponseSchema", () =>
75
75
  ).toBe(false);
76
76
  });
77
77
  });
78
+
79
+ describe("connectionUpdateRequestSchema", () => {
80
+ test("accepts the updated_at snapshot used for generic OIDC compare-and-set", () => {
81
+ expect(
82
+ connectionUpdateRequestSchema.safeParse({
83
+ owner_confirmed: true,
84
+ expected_updated_at: VALID_CONNECTION.updated_at,
85
+ }).success,
86
+ ).toBe(true);
87
+ });
88
+ });
@@ -113,6 +113,7 @@ export type ConnectionGetResponse = z.infer<typeof connectionGetResponseSchema>;
113
113
  // ---------------------------------------------------------------------------
114
114
 
115
115
  export const connectionUpdateRequestSchema = z.strictObject({
116
+ /** Reviewed row's `updated_at`; required for generic OIDC mutations unless `If-Match` is used. */
116
117
  expected_updated_at: z.iso
117
118
  .datetime()
118
119
  .optional()
package/src/rbac.test.ts CHANGED
@@ -90,8 +90,8 @@ describe("design.md §27.2 role table invariants", () => {
90
90
  }
91
91
  });
92
92
 
93
- test("dead-letter scopes: read for owner/admin/developer/viewer, re-drive for owner/admin only (design.md §29.3, §27.2)", () => {
94
- const readers = ["owner", "admin", "developer", "viewer"] as const;
93
+ test("dead-letter scopes: read for owner/admin/developer, re-drive for owner/admin only (design.md §29.3, §27.2)", () => {
94
+ const readers = ["owner", "admin", "developer"] as const;
95
95
  const writers = ["owner", "admin"] as const;
96
96
  for (const role of WORKSPACE_ROLES) {
97
97
  expect(roleHasScope(role, "dlq:read"), `dlq:read for ${role}`).toBe(
package/src/rbac.ts CHANGED
@@ -121,10 +121,9 @@ export const IMPERSONATION_FORBIDDEN_SCOPES = [
121
121
  * billing/viewer, withheld from developer. The Developer table lists "Client,
122
122
  * Connection, Domain, Webhook" resources, with `introspect` as a standalone
123
123
  * OAuth capability for resource-server token validation. `dlq:read` is limited
124
- * to inspection; `dlq:write` is Owner/Admin-only because redrive covers every
125
- * source queue. Every other role either reads broadly (`viewer`, "読み取りのみ") or
126
- * needs the roster for its work (`admin` administers the workspace;
127
- * `support`/`billing` deal with the workspace's people and billing contacts day to day).
124
+ * to Owner/Admin/Developer, with Developer read-only; Viewer is excluded because
125
+ * DLQ records may include billing or audit data. `dlq:write` is Owner/Admin-only
126
+ * because redrive covers every source queue.
128
127
  */
129
128
  export const ROLE_SCOPES: Readonly<Record<WorkspaceRole, readonly ManagementScope[]>> = {
130
129
  owner: MANAGEMENT_SCOPES,
@@ -197,7 +196,6 @@ export const ROLE_SCOPES: Readonly<Record<WorkspaceRole, readonly ManagementScop
197
196
  "user_sessions:read",
198
197
  "user_data_jobs:read",
199
198
  "webhooks:read",
200
- "dlq:read",
201
199
  "audit_events:read",
202
200
  "usage:read",
203
201
  "billing:read",
@@ -16,7 +16,6 @@ describe("userImportJobSchema", () => {
16
16
  environment_id: ENVIRONMENT_ID,
17
17
  status: "processing",
18
18
  format: "csv",
19
- source_url: "https://uploads.example.com/import.csv",
20
19
  total_records: 100,
21
20
  processed_records: 40,
22
21
  succeeded_records: 38,
@@ -29,6 +28,26 @@ describe("userImportJobSchema", () => {
29
28
  }).success,
30
29
  ).toBe(true);
31
30
  });
31
+ test("rejects a request-only source URL in job metadata", () => {
32
+ expect(
33
+ userImportJobSchema.safeParse({
34
+ id: `job_${"a".repeat(32)}`,
35
+ environment_id: ENVIRONMENT_ID,
36
+ status: "failed",
37
+ format: "json",
38
+ source_url: "https://uploads.example.com/import.json?signature=sentinel",
39
+ total_records: null,
40
+ processed_records: 0,
41
+ succeeded_records: 0,
42
+ failed_records: 0,
43
+ error_report_url: null,
44
+ created_by: { actor_type: "workspace_member", actor_id: `usr_${"a".repeat(32)}` },
45
+ created_at: "2026-08-02T08:10:00Z",
46
+ updated_at: "2026-08-02T08:10:00Z",
47
+ completed_at: "2026-08-02T08:10:00Z",
48
+ }).success,
49
+ ).toBe(false);
50
+ });
32
51
 
33
52
  test("rejects an unknown top-level key", () => {
34
53
  expect(
package/src/user-jobs.ts CHANGED
@@ -14,9 +14,9 @@ import { environmentIdSchema, jobIdSchema, userIdSchema } from "./primitives.js"
14
14
  * (private key, provider token, internal risk score).
15
15
  * - the async job lifecycle convention used elsewhere in the schema, e.g.
16
16
  * `email_deliveries.status` (§12.8) and `outbox_events.status` (§11.16).
17
- * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB) —
18
- * bulk import records and export output are therefore referenced by an R2
19
- * URL, never embedded inline in the job resource itself.
17
+ * - design.md §14.0's "1 row/valueは64 KB以下" (rows/values capped at 64 KB):
18
+ * import source URLs are request-only capabilities, while export artifacts
19
+ * are accessed through their scoped download route; neither is embedded.
20
20
  *
21
21
  * Should a future design.md revision add explicit
22
22
  * `user_import_jobs`/`user_export_jobs` tables, this file's field set should
@@ -46,8 +46,6 @@ export const userImportJobSchema = z.strictObject({
46
46
  environment_id: environmentIdSchema,
47
47
  status: jobStatusSchema,
48
48
  format: userImportFormatSchema,
49
- /** Where the platform fetched the source records from (an R2/customer-hosted HTTPS URL). */
50
- source_url: httpsUrlSchema,
51
49
  total_records: z.number().int().nonnegative().nullable(),
52
50
  processed_records: z.number().int().nonnegative(),
53
51
  succeeded_records: z.number().int().nonnegative(),
@@ -64,6 +62,7 @@ export type UserImportJob = z.infer<typeof userImportJobSchema>;
64
62
  export const userImportJobCreateRequestSchema = z.strictObject({
65
63
  environment_id: environmentIdSchema,
66
64
  format: userImportFormatSchema,
65
+ /** A transient fetch capability; never persisted or returned in job metadata. */
67
66
  source_url: httpsUrlSchema,
68
67
  });
69
68
  export type UserImportJobCreateRequest = z.infer<typeof userImportJobCreateRequestSchema>;