@onesi/genesis 0.2.0 → 0.2.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/README.md +1 -1
- package/dist/blinds-owner-enrollment.d.ts +12 -0
- package/dist/blinds-owner-enrollment.js +2 -0
- package/dist/boxes.d.ts +1074 -0
- package/dist/boxes.js +338 -0
- package/dist/client.js +6 -4
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +37 -2
- package/dist/flocks.d.ts +49 -0
- package/dist/flocks.js +30 -4
- package/dist/foundry.d.ts +5 -0
- package/dist/foundry.js +2 -0
- package/dist/generated/operations.d.ts +1 -1
- package/dist/generated/operations.js +9512 -9
- package/dist/generated/schema.d.ts +55061 -38962
- package/dist/genesis.d.ts +1150 -7
- package/dist/genesis.js +2 -0
- package/dist/genesis.openapi.json +55788 -33084
- package/dist/hives-cells.d.ts +8 -3
- package/dist/hives-cells.js +17 -4
- package/dist/hives-node.js +2 -2
- package/dist/hives-operations.d.ts +7 -3
- package/dist/hives-resources-transport.d.ts +7 -1
- package/dist/hives-resources-transport.js +10 -2
- package/dist/hives-topics.d.ts +4 -3
- package/dist/hives-topics.js +9 -4
- package/dist/iam.d.ts +7 -1
- package/dist/idempotency.js +5 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -1
- package/dist/redact.d.ts +37 -0
- package/dist/redact.js +330 -0
- package/dist/scopes.d.ts +6 -0
- package/package.json +1 -1
package/dist/hives-cells.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenesisClient } from './client.js';
|
|
2
|
-
import { type HivesResourceOptions } from './hives-resources-transport.js';
|
|
2
|
+
import { type HivesFundedWriteOptions, type HivesResourceOptions } from './hives-resources-transport.js';
|
|
3
3
|
export interface HivesCorsRule {
|
|
4
4
|
allowed_origins: string[];
|
|
5
5
|
allowed_methods: string[];
|
|
@@ -112,16 +112,21 @@ export declare function hivesCells(client: GenesisClient): {
|
|
|
112
112
|
continuation_token?: string;
|
|
113
113
|
max_keys?: number;
|
|
114
114
|
}, options?: HivesResourceOptions): Promise<HivesObjectList>;
|
|
115
|
-
put(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?:
|
|
115
|
+
put(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: HivesFundedWriteOptions & {
|
|
116
116
|
content_type?: string;
|
|
117
117
|
}): Promise<HivesObjectAcknowledgement>;
|
|
118
118
|
remove: (project: string, id: string, key: string, options?: HivesResourceOptions) => Promise<void>;
|
|
119
119
|
download: (project: string, id: string, key: string, options?: HivesResourceOptions) => Promise<Response>;
|
|
120
120
|
/** Existing flat-key path compatibility; nested keys use canonical collection methods above. */
|
|
121
|
-
putFlat(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?:
|
|
121
|
+
putFlat(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: HivesFundedWriteOptions & {
|
|
122
122
|
content_type?: string;
|
|
123
123
|
}): Promise<HivesObjectAcknowledgement>;
|
|
124
124
|
removeFlat: (project: string, id: string, key: string, options?: HivesResourceOptions) => Promise<void>;
|
|
125
|
+
/** The flat key "download" on its own static route, which shadows /objects/{key} for that key. */
|
|
126
|
+
putDownload(project: string, id: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: HivesFundedWriteOptions & {
|
|
127
|
+
content_type?: string;
|
|
128
|
+
}): Promise<HivesObjectAcknowledgement>;
|
|
129
|
+
removeDownload: (project: string, id: string, options?: HivesResourceOptions) => Promise<void>;
|
|
125
130
|
};
|
|
126
131
|
presign(project: string, id: string, body: HivesPresign, options?: HivesResourceOptions): Promise<HivesPresignedUrl>;
|
|
127
132
|
};
|
package/dist/hives-cells.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HIVES_OBJECT_BYTES, hivesResourceCall, hivesResourceId, hivesObjectBody, hivesContentType, resourceError } from './hives-resources-transport.js';
|
|
1
|
+
import { HIVES_OBJECT_BYTES, hivesFundedWriteHeaders, hivesResourceCall, hivesResourceId, hivesObjectBody, hivesContentType, resourceError } from './hives-resources-transport.js';
|
|
2
2
|
export function hivesObjectKey(key) {
|
|
3
3
|
const bytes = new TextEncoder().encode(key);
|
|
4
4
|
if (typeof key !== 'string' || !key || bytes.length > 1024 || new TextDecoder('utf-8', { fatal: true }).decode(bytes) !== key
|
|
@@ -59,7 +59,12 @@ function object(value, id) {
|
|
|
59
59
|
hivesObjectKey(value.key);
|
|
60
60
|
return Object.fromEntries(['key', 'bucket_id', 'size_bytes', 'etag', 'last_modified', 'generation', 'content_type', 'metadata', 'metadata_scope'].map(k => [k, value[k]]));
|
|
61
61
|
}
|
|
62
|
-
function acknowledgement(
|
|
62
|
+
function acknowledgement(answer, key, id, size) {
|
|
63
|
+
// A funded write answers with its settled storage operation receipt; the acknowledgement is its result.
|
|
64
|
+
const receipt = answer;
|
|
65
|
+
if (receipt && receipt.object !== undefined && (receipt.object !== 'storage_write_operation' || receipt.state !== 'settled'))
|
|
66
|
+
throw resourceError(0);
|
|
67
|
+
const value = (receipt?.object === undefined ? answer : receipt.result);
|
|
63
68
|
if (!value || value.bucket_id !== id || value.key !== key || value.size_bytes !== size || !Number.isSafeInteger(value.size_bytes) || value.size_bytes < 0 || typeof value.etag !== 'string' || typeof value.generation !== 'string' || value.content_type !== null && typeof value.content_type !== 'string')
|
|
64
69
|
throw resourceError(0);
|
|
65
70
|
return { key: value.key, bucket_id: value.bucket_id, size_bytes: value.size_bytes, etag: value.etag, generation: value.generation, content_type: value.content_type };
|
|
@@ -67,6 +72,8 @@ function acknowledgement(value, key, id, size) {
|
|
|
67
72
|
export function hivesCells(client) {
|
|
68
73
|
const ids = (project_id, bucket_id) => ({ project_id: hivesResourceId(project_id), ...(bucket_id === undefined ? {} : { bucket_id: hivesResourceId(bucket_id) }) });
|
|
69
74
|
const call = (id, input, options, mode = 'json', limit = 2 * 1024 * 1024) => hivesResourceCall(client, id, input, options, mode, limit, 100_000);
|
|
75
|
+
// Object writes are funded: each carries one Idempotency-Key (the caller's, or a fresh one).
|
|
76
|
+
const write = (id, input, options) => hivesResourceCall(client, id, input, options, 'json', 2 * 1024 * 1024, 100_000, undefined, { headers: hivesFundedWriteHeaders(options, id) });
|
|
70
77
|
return {
|
|
71
78
|
async list(project, query = {}, options) {
|
|
72
79
|
if (Object.keys(query).some(k => !['page', 'per_page'].includes(k)) || query.page !== undefined && (!Number.isInteger(query.page) || query.page < 1 || query.page > 10000) || query.per_page !== undefined && (!Number.isInteger(query.per_page) || query.per_page < 1 || query.per_page > 100))
|
|
@@ -113,7 +120,7 @@ export function hivesCells(client) {
|
|
|
113
120
|
async put(project, id, key, bytes, options = {}) {
|
|
114
121
|
const body = await hivesObjectBody(bytes);
|
|
115
122
|
const content_type = hivesContentType(options.content_type);
|
|
116
|
-
return acknowledgement(await
|
|
123
|
+
return acknowledgement(await write('hives_upload_object_by_key', { ...ids(project, id), key_base64url: hivesObjectKey(key), body, content_type }, options), key, id, body.byteLength);
|
|
117
124
|
},
|
|
118
125
|
remove: (project, id, key, options) => call('hives_delete_object_by_key', { ...ids(project, id), key_base64url: hivesObjectKey(key) }, options, 'empty'),
|
|
119
126
|
download: (project, id, key, options) => call('hives_download_object_by_key', { ...ids(project, id), key_base64url: hivesObjectKey(key) }, options, 'binary', HIVES_OBJECT_BYTES),
|
|
@@ -123,10 +130,16 @@ export function hivesCells(client) {
|
|
|
123
130
|
if (!/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/.test(key))
|
|
124
131
|
throw resourceError(0);
|
|
125
132
|
const body = await hivesObjectBody(bytes);
|
|
126
|
-
return acknowledgement(await
|
|
133
|
+
return acknowledgement(await write('hives_upload_object', { ...ids(project, id), key, body, content_type: hivesContentType(options.content_type) }, options), key, id, body.byteLength);
|
|
127
134
|
},
|
|
128
135
|
removeFlat: (project, id, key, options) => { hivesObjectKey(key); if (!/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/.test(key))
|
|
129
136
|
throw resourceError(0); return call('hives_delete_object', { ...ids(project, id), key }, options, 'empty'); },
|
|
137
|
+
/** The flat key "download" on its own static route, which shadows /objects/{key} for that key. */
|
|
138
|
+
async putDownload(project, id, bytes, options = {}) {
|
|
139
|
+
const body = await hivesObjectBody(bytes);
|
|
140
|
+
return acknowledgement(await write('hives_upload_object_named_download', { ...ids(project, id), body, content_type: hivesContentType(options.content_type) }, options), 'download', id, body.byteLength);
|
|
141
|
+
},
|
|
142
|
+
removeDownload: (project, id, options) => call('hives_delete_object_named_download', ids(project, id), options, 'empty'),
|
|
130
143
|
},
|
|
131
144
|
async presign(project, id, body, options) {
|
|
132
145
|
hivesObjectKey(body.key);
|
package/dist/hives-node.js
CHANGED
|
@@ -12,12 +12,12 @@ export async function closeHivesNodeTransport() {
|
|
|
12
12
|
await current?.destroy();
|
|
13
13
|
}
|
|
14
14
|
export function hivesOperationBudget(id) {
|
|
15
|
-
if (['hives_list_buckets', 'hives_create_bucket', 'hives_get_bucket', 'hives_delete_bucket', 'hives_list_objects', 'hives_upload_object', 'hives_upload_object_by_key', 'hives_delete_object', 'hives_delete_object_by_key', 'hives_download_object_by_key', 'hives_get_cors_config', 'hives_set_cors_config', 'hives_generate_presigned_url', 'hives_reconcile'].includes(id))
|
|
15
|
+
if (['hives_list_buckets', 'hives_create_bucket', 'hives_get_bucket', 'hives_delete_bucket', 'hives_list_objects', 'hives_upload_object', 'hives_upload_object_by_key', 'hives_upload_object_named_download', 'hives_delete_object', 'hives_delete_object_by_key', 'hives_delete_object_named_download', 'hives_download_object_by_key', 'hives_get_cors_config', 'hives_set_cors_config', 'hives_generate_presigned_url', 'hives_reconcile'].includes(id))
|
|
16
16
|
return 100_000;
|
|
17
17
|
if (id === 'hives_cancel_deployment' || id === 'hives_delete_deployment' || id === 'hives_stop_deployment')
|
|
18
18
|
return 330_000;
|
|
19
19
|
// A live SSE subscription is bounded by its caller's window or --follow limit (at most 300 s).
|
|
20
|
-
if (id === 'hives_stream_logs')
|
|
20
|
+
if (id === 'hives_stream_logs' || id === 'hives_stream_deployment_logs')
|
|
21
21
|
return 330_000;
|
|
22
22
|
if (['hives_create_deployment', 'hives_upload_deployment', 'hives_invoke_deployment', 'hives_invoke_function', 'hives_invoke_function_async'].includes(id))
|
|
23
23
|
return 40_000;
|
|
@@ -29,15 +29,19 @@ export declare function hivesOperations(client: GenesisClient): {
|
|
|
29
29
|
continuation_token?: string;
|
|
30
30
|
max_keys?: number;
|
|
31
31
|
}, options?: import("./hives-resources-transport.js").HivesResourceOptions): Promise<import("./hives-cells.js").HivesObjectList>;
|
|
32
|
-
put(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: import("./hives-resources-transport.js").
|
|
32
|
+
put(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: import("./hives-resources-transport.js").HivesFundedWriteOptions & {
|
|
33
33
|
content_type?: string;
|
|
34
34
|
}): Promise<import("./hives-cells.js").HivesObjectAcknowledgement>;
|
|
35
35
|
remove: (project: string, id: string, key: string, options?: import("./hives-resources-transport.js").HivesResourceOptions) => Promise<void>;
|
|
36
36
|
download: (project: string, id: string, key: string, options?: import("./hives-resources-transport.js").HivesResourceOptions) => Promise<Response>;
|
|
37
|
-
putFlat(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: import("./hives-resources-transport.js").
|
|
37
|
+
putFlat(project: string, id: string, key: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: import("./hives-resources-transport.js").HivesFundedWriteOptions & {
|
|
38
38
|
content_type?: string;
|
|
39
39
|
}): Promise<import("./hives-cells.js").HivesObjectAcknowledgement>;
|
|
40
40
|
removeFlat: (project: string, id: string, key: string, options?: import("./hives-resources-transport.js").HivesResourceOptions) => Promise<void>;
|
|
41
|
+
putDownload(project: string, id: string, bytes: Blob | ArrayBuffer | ArrayBufferView, options?: import("./hives-resources-transport.js").HivesFundedWriteOptions & {
|
|
42
|
+
content_type?: string;
|
|
43
|
+
}): Promise<import("./hives-cells.js").HivesObjectAcknowledgement>;
|
|
44
|
+
removeDownload: (project: string, id: string, options?: import("./hives-resources-transport.js").HivesResourceOptions) => Promise<void>;
|
|
41
45
|
};
|
|
42
46
|
presign(project: string, id: string, body: import("./hives-cells.js").HivesPresign, options?: import("./hives-resources-transport.js").HivesResourceOptions): Promise<import("./hives-cells.js").HivesPresignedUrl>;
|
|
43
47
|
};
|
|
@@ -125,7 +129,7 @@ export declare function hivesOperations(client: GenesisClient): {
|
|
|
125
129
|
deleted: true;
|
|
126
130
|
}>;
|
|
127
131
|
};
|
|
128
|
-
publish(project: string, id: string, body: import("./hives-topics.js").HivesTopicPublish, options?: import("./hives-resources-transport.js").
|
|
132
|
+
publish(project: string, id: string, body: import("./hives-topics.js").HivesTopicPublish, options?: import("./hives-resources-transport.js").HivesFundedWriteOptions): Promise<import("./hives-topics.js").HivesTopicPublication>;
|
|
129
133
|
};
|
|
130
134
|
runtimes: {
|
|
131
135
|
list: (options?: import("./hives-resources-transport.js").HivesResourceOptions) => Promise<{
|
|
@@ -6,12 +6,18 @@ export declare const HIVES_RESOURCE_JSON_BYTES: number;
|
|
|
6
6
|
export interface HivesResourceOptions {
|
|
7
7
|
signal?: AbortSignal;
|
|
8
8
|
}
|
|
9
|
+
/** Funded Hives writes (topic publish, Cells object writes): Hives refuses them without one Idempotency-Key. */
|
|
10
|
+
export interface HivesFundedWriteOptions extends HivesResourceOptions {
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The caller's key, or a fresh one when none is given. Reuse a key only to replay the same write, never to act twice. */
|
|
14
|
+
export declare function hivesFundedWriteHeaders(options?: HivesFundedWriteOptions, id?: string): Record<string, string>;
|
|
9
15
|
export declare function hivesResourceId(value: string): string;
|
|
10
16
|
export declare function resourceError(status: number, id?: string): GenesisError;
|
|
11
17
|
/** A non-2xx Hives resource reply as a GenesisError with the gateway's code, request id and required scope (bounded read, body discarded). */
|
|
12
18
|
export declare function resourceErrorFromResponse(response: Response, id?: string): Promise<GenesisError>;
|
|
13
19
|
export declare const isHivesResourceOperation: (id: string) => boolean;
|
|
14
|
-
export declare const isHivesObjectUpload: (id: string) => id is "hives_upload_object_by_key" | "hives_upload_object";
|
|
20
|
+
export declare const isHivesObjectUpload: (id: string) => id is "hives_upload_object_by_key" | "hives_upload_object_named_download" | "hives_upload_object";
|
|
15
21
|
/** Shared-client hook proposal: snapshot only the two real raw Cells upload operations. */
|
|
16
22
|
export declare function hivesObjectBody(value: unknown): Promise<ArrayBuffer>;
|
|
17
23
|
export declare function hivesContentType(value?: string): string;
|
|
@@ -2,6 +2,14 @@ import { GenesisError } from './errors.js';
|
|
|
2
2
|
export const HIVES_OBJECT_BYTES = 10 * 1024 * 1024;
|
|
3
3
|
export const HIVES_QUEUE_BYTES = 256 * 1024;
|
|
4
4
|
export const HIVES_RESOURCE_JSON_BYTES = 2 * 1024 * 1024;
|
|
5
|
+
/** The caller's key, or a fresh one when none is given. Reuse a key only to replay the same write, never to act twice. */
|
|
6
|
+
export function hivesFundedWriteHeaders(options = {}, id) {
|
|
7
|
+
const key = options.idempotencyKey ?? globalThis.crypto.randomUUID();
|
|
8
|
+
// Hives' bound (operation_funding.rs key()): one value of 1-128 printable ASCII bytes.
|
|
9
|
+
if (typeof key !== 'string' || !/^[ -~]{1,128}$/.test(key))
|
|
10
|
+
throw resourceError(0, id);
|
|
11
|
+
return { 'idempotency-key': key };
|
|
12
|
+
}
|
|
5
13
|
export function hivesResourceId(value) {
|
|
6
14
|
if (typeof value !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(value))
|
|
7
15
|
throw resourceError(0);
|
|
@@ -50,8 +58,8 @@ export async function resourceErrorFromResponse(response, id) {
|
|
|
50
58
|
code: fields.code, requestId: fields.requestId,
|
|
51
59
|
body: fields.code || fields.requiredScope ? { error: { code: fields.code, request_id: fields.requestId, required_scope: fields.requiredScope } } : undefined });
|
|
52
60
|
}
|
|
53
|
-
export const isHivesResourceOperation = (id) => /^(?:hives_marketplace_(?:categories|featured|installed|get_installation|uninstall|reconcile|list_packages|publish|get_package|install|update|list_versions)|hives_(?:get|configure|remove)_native_queue_consumer|hives_.*_native_queue|hives_.*_native_topic|hives_(?:(?:list_volumes|create_volume|get_volume|delete_volume|mount_volume|unmount_volume)|list_buckets|create_bucket|get_bucket|delete_bucket|list_objects|upload_object(?:_by_key)?|delete_object(?:_by_key)?|download_object_by_key|get_cors_config|set_cors_config|generate_presigned_url|reconcile|list_runtimes|get_runtime|select_runtime|list_project_runtimes))$/.test(id);
|
|
54
|
-
export const isHivesObjectUpload = (id) => id === 'hives_upload_object_by_key' || id === 'hives_upload_object';
|
|
61
|
+
export const isHivesResourceOperation = (id) => /^(?:hives_marketplace_(?:categories|featured|installed|get_installation|uninstall|reconcile|list_packages|publish|get_package|install|update|list_versions)|hives_(?:get|configure|remove)_native_queue_consumer|hives_.*_native_queue|hives_.*_native_topic|hives_(?:(?:list_volumes|create_volume|get_volume|delete_volume|mount_volume|unmount_volume)|list_buckets|create_bucket|get_bucket|delete_bucket|list_objects|upload_object(?:_by_key|_named_download)?|delete_object(?:_by_key|_named_download)?|download_object_by_key|get_cors_config|set_cors_config|generate_presigned_url|reconcile|list_runtimes|get_runtime|select_runtime|list_project_runtimes))$/.test(id);
|
|
62
|
+
export const isHivesObjectUpload = (id) => id === 'hives_upload_object_by_key' || id === 'hives_upload_object' || id === 'hives_upload_object_named_download';
|
|
55
63
|
/** Shared-client hook proposal: snapshot only the two real raw Cells upload operations. */
|
|
56
64
|
export async function hivesObjectBody(value) {
|
|
57
65
|
let bytes;
|
package/dist/hives-topics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenesisClient } from './client.js';
|
|
2
|
-
import { type HivesResourceOptions } from './hives-resources-transport.js';
|
|
2
|
+
import { type HivesFundedWriteOptions, type HivesResourceOptions } from './hives-resources-transport.js';
|
|
3
3
|
export interface HivesTopic {
|
|
4
4
|
id: string;
|
|
5
5
|
projectId: string;
|
|
@@ -46,6 +46,7 @@ export declare function hivesTopics(client: GenesisClient): {
|
|
|
46
46
|
deleted: true;
|
|
47
47
|
}>;
|
|
48
48
|
};
|
|
49
|
-
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome.
|
|
50
|
-
|
|
49
|
+
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome. Carries one
|
|
50
|
+
* Idempotency-Key (options.idempotencyKey, or a fresh one); reuse that key only to replay this publication. */
|
|
51
|
+
publish(project: string, id: string, body: HivesTopicPublish, options?: HivesFundedWriteOptions): Promise<HivesTopicPublication>;
|
|
51
52
|
};
|
package/dist/hives-topics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hivesQueueBody } from './hives-queues.js';
|
|
2
|
-
import { HIVES_QUEUE_BYTES, hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
|
|
2
|
+
import { HIVES_QUEUE_BYTES, hivesFundedWriteHeaders, hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
|
|
3
3
|
const invalid = () => resourceError(0);
|
|
4
4
|
const object = (v) => { if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
5
5
|
throw invalid(); return v; };
|
|
@@ -46,7 +46,7 @@ function publishInput(value) {
|
|
|
46
46
|
}
|
|
47
47
|
export function hivesTopics(client) {
|
|
48
48
|
const ids = (project, id) => ({ project_id: hivesResourceId(project), ...(id === undefined ? {} : { topic_id: hivesResourceId(id) }) });
|
|
49
|
-
const call = (operation, input, options, status = 200) => hivesResourceCall(client, operation, input, options, 'json', 2 * 1024 * 1024, 20_000, status);
|
|
49
|
+
const call = (operation, input, options, status = 200, headers) => hivesResourceCall(client, operation, input, options, 'json', 2 * 1024 * 1024, 20_000, status, headers && { headers });
|
|
50
50
|
const removed = (value) => { if (object(value).deleted !== true)
|
|
51
51
|
throw invalid(); return { deleted: true }; };
|
|
52
52
|
return {
|
|
@@ -64,10 +64,15 @@ export function hivesTopics(client) {
|
|
|
64
64
|
async add(project, id, queueId, options) { const queue = hivesResourceId(queueId); return subscription(await call('hives_subscribe_native_topic', { ...ids(project, id), body: { queueId: queue } }, options, 201), project, id, queue); },
|
|
65
65
|
async remove(project, id, subscriptionId, options) { return removed(await call('hives_unsubscribe_native_topic', { ...ids(project, id), subscription_id: hivesResourceId(subscriptionId) }, options)); },
|
|
66
66
|
},
|
|
67
|
-
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome.
|
|
67
|
+
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome. Carries one
|
|
68
|
+
* Idempotency-Key (options.idempotencyKey, or a fresh one); reuse that key only to replay this publication. */
|
|
68
69
|
async publish(project, id, body, options) {
|
|
69
70
|
publishInput(body);
|
|
70
|
-
const
|
|
71
|
+
const headers = hivesFundedWriteHeaders(options, 'hives_publish_native_topic');
|
|
72
|
+
const v = object(await call('hives_publish_native_topic', { ...ids(project, id), body }, options, 201, headers));
|
|
73
|
+
// A funded publication answers with its settled operation receipt, which carries the same publication fields.
|
|
74
|
+
if (v.object !== undefined && (v.object !== 'pubsub_publish_operation' || v.state !== 'settled'))
|
|
75
|
+
throw invalid();
|
|
71
76
|
if (!Array.isArray(v.deliveries) || v.deliveries.length > 32)
|
|
72
77
|
throw invalid();
|
|
73
78
|
const deliveries = v.deliveries.map(raw => { const d = object(raw); return { subscription_id: nativeId(d.subscription_id, 'sub'), queue_id: hivesResourceId(d.queue_id), message_id: hivesResourceId(d.message_id) }; });
|
package/dist/iam.d.ts
CHANGED
|
@@ -363,7 +363,13 @@ export declare function iamModule(client: GenesisClient): {
|
|
|
363
363
|
next_cursor?: string | null;
|
|
364
364
|
}>;
|
|
365
365
|
tenantContext: () => Promise<{
|
|
366
|
-
|
|
366
|
+
organizationId: string;
|
|
367
|
+
projectId: string;
|
|
368
|
+
platformId: string;
|
|
369
|
+
workspaceId?: string;
|
|
370
|
+
fleetId?: string;
|
|
371
|
+
organizationName?: string;
|
|
372
|
+
environmentId?: string;
|
|
367
373
|
}>;
|
|
368
374
|
checkPermission: (body: Body<"iam_checkPermission">) => Promise<{
|
|
369
375
|
allowed: boolean;
|
package/dist/idempotency.js
CHANGED
|
@@ -15,6 +15,11 @@ export function idempotencyHeaders(operationId, key) {
|
|
|
15
15
|
message: need === 'required' ? `${operationId} needs a stable idempotency key (8-128 printable ASCII characters)`
|
|
16
16
|
: need ? `${operationId} idempotency key must be 1-256 printable ASCII characters` : `${operationId} does not take an idempotency key` });
|
|
17
17
|
}
|
|
18
|
+
// Zaps (spec IdempotencyKey, gateway key lane) admits only 8-128 printable characters, required or optional.
|
|
19
|
+
if (operationTable[operationId].service === 'zaps' && !REQUIRED.test(key)) {
|
|
20
|
+
throw new GenesisError({ status: 0, type: 'invalid_request', operationId,
|
|
21
|
+
message: `${operationId} idempotency key must be 8-128 printable ASCII characters` });
|
|
22
|
+
}
|
|
18
23
|
// Auto takes 8-128 characters of [A-Za-z0-9_.:-] (its authority check); refuse anything it would 422 before sending.
|
|
19
24
|
if (operationTable[operationId].service === 'auto' && !AUTO_KEY.test(key)) {
|
|
20
25
|
throw new GenesisError({ status: 0, type: 'invalid_request', operationId,
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export { Genesis, type ChatMessage } from './genesis.js';
|
|
|
2
2
|
export { GenesisClient, DEFAULT_BASE_URL, type GenesisOptions, type CredentialProvider } from './client.js';
|
|
3
3
|
export { iamDirectoryOperations, isIamDirectoryOperation, iamDirectoryFailure } from './iam-directory.js';
|
|
4
4
|
export { iamModule } from './iam.js';
|
|
5
|
-
export { GenesisError, errorCatalog, errorToken, errorOutcome } from './errors.js';
|
|
5
|
+
export { GenesisError, errorCatalog, errorBody, errorToken, errorOutcome } from './errors.js';
|
|
6
|
+
export { ERROR_BODY_LIMITS, cardNumber, redactErrorBody, redactErrorText, secretField } from './redact.js';
|
|
6
7
|
export { requireSecureUrl } from './urls.js';
|
|
7
8
|
export { operationTable, services, type OperationId } from './generated/operations.js';
|
|
8
9
|
export type { OperationInput, OperationOutput, OperationMeta, ServiceMeta } from './types.js';
|
|
@@ -20,19 +21,20 @@ export { tapsModule } from './taps.js';
|
|
|
20
21
|
export { lanesModule } from './lanes.js';
|
|
21
22
|
export { flaresModule } from './flares.js';
|
|
22
23
|
export { idempotencyHeaders, ifMatchHeaders } from './idempotency.js';
|
|
23
|
-
export type { FlocksWriteOptions, WaitForJobOptions, FlocksJob } from './flocks.js';
|
|
24
|
+
export type { FlocksWriteOptions, WaitForJobOptions, FlocksJob, FlocksRun } from './flocks.js';
|
|
24
25
|
export { autoModule } from './auto.js';
|
|
25
26
|
export { gardenModule } from './garden.js';
|
|
26
27
|
export { orgsEntitiesModule, type OrgsDocumentContent } from './orgs.js';
|
|
27
28
|
export { scopesModule } from './scopes.js';
|
|
28
29
|
export { billingModule, gatewayModule, orgsModule } from './gateway.js';
|
|
30
|
+
export { boxesModule } from './boxes.js';
|
|
29
31
|
export { dialsModule, dialsEmergencyAddressFeedback, type DialsEmergencyAddressFeedback, type DialsScope, type DialsOutboundCall, type DialsCallControl, type DialsEmergencyAddress, type DialsCallListItem, type DialsCallDispatchState, type DialsMessage, type DialsMessageTemplate, type DialsMessagingBrand, type DialsMessagingCampaign, type DialsWorkflowDocument, type DialsRoutingAction, type DialsRoutingRule, type DialsRoutingRuleReceipt, type DialsOutboundCallReceipt, type DialsRecoveredOutboundCallReceipt } from './dials.js';
|
|
30
32
|
export { hivesObjectKey, type HivesBucket, type HivesObject, type HivesObjectAcknowledgement, type HivesObjectList, type HivesCorsRule, type HivesCreateBucket, type HivesPresign, type HivesPresignedUrl } from './hives-cells.js';
|
|
31
33
|
export { hivesSseEvents, hivesSseReader, type HivesLogStreamEvent, type HivesLogStreamQuery, type HivesLogWindow, type HivesLogWindowOptions } from './hives-platform.js';
|
|
32
34
|
export { hivesQueueBody, type HivesQueue, type HivesQueueConfig, type HivesQueueCreate, type HivesQueueSend, type HivesQueueDelivery, type HivesDeadLetter, type HivesDeadLetterStats } from './hives-queues.js';
|
|
33
35
|
export type { HivesRuntime, HivesRuntimeSelection } from './hives-runtimes.js';
|
|
34
36
|
export type { HivesVolume, HivesVolumeCreate, HivesVolumeMount, HivesVolumePage } from './hives-volumes.js';
|
|
35
|
-
export { HIVES_OBJECT_BYTES, HIVES_QUEUE_BYTES, type HivesResourceOptions } from './hives-resources-transport.js';
|
|
37
|
+
export { HIVES_OBJECT_BYTES, HIVES_QUEUE_BYTES, type HivesResourceOptions, type HivesFundedWriteOptions } from './hives-resources-transport.js';
|
|
36
38
|
export type { HivesMarketplacePackage, HivesMarketplaceVersion, HivesMarketplaceInstallation, HivesMarketplaceCategory, HivesMarketplacePage, HivesMarketplacePublish, HivesMarketplaceInstall, HivesMarketplaceSearch, HivesMarketplaceDetail } from './hives-marketplace.js';
|
|
37
39
|
export type { HivesQueueConsumerConfig, HivesQueueConsumerBinding, HivesQueueConsumerAttempt, HivesQueueConsumerStatus } from './hives-queue-consumer.js';
|
|
38
40
|
export { foundryBillingOperations, isFoundryBillingOperation } from './foundry-billing.js';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@ export { Genesis } from './genesis.js';
|
|
|
2
2
|
export { GenesisClient, DEFAULT_BASE_URL } from './client.js';
|
|
3
3
|
export { iamDirectoryOperations, isIamDirectoryOperation, iamDirectoryFailure } from './iam-directory.js';
|
|
4
4
|
export { iamModule } from './iam.js';
|
|
5
|
-
export { GenesisError, errorCatalog, errorToken, errorOutcome } from './errors.js';
|
|
5
|
+
export { GenesisError, errorCatalog, errorBody, errorToken, errorOutcome } from './errors.js';
|
|
6
|
+
export { ERROR_BODY_LIMITS, cardNumber, redactErrorBody, redactErrorText, secretField } from './redact.js';
|
|
6
7
|
export { requireSecureUrl } from './urls.js';
|
|
7
8
|
export { operationTable, services } from './generated/operations.js';
|
|
8
9
|
export { hivesUploadBody, MAX_WASM_BYTES } from './hives-upload.js';
|
|
@@ -21,6 +22,7 @@ export { gardenModule } from './garden.js';
|
|
|
21
22
|
export { orgsEntitiesModule } from './orgs.js';
|
|
22
23
|
export { scopesModule } from './scopes.js';
|
|
23
24
|
export { billingModule, gatewayModule, orgsModule } from './gateway.js';
|
|
25
|
+
export { boxesModule } from './boxes.js';
|
|
24
26
|
export { dialsModule, dialsEmergencyAddressFeedback } from './dials.js';
|
|
25
27
|
export { hivesObjectKey } from './hives-cells.js';
|
|
26
28
|
export { hivesSseEvents, hivesSseReader } from './hives-platform.js';
|
package/dist/redact.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction for service error bodies and messages before the CLI or MCP prints them. The design is
|
|
3
|
+
* conservative: when a key or value might be a secret, it is replaced with `[redacted]`. Field names are
|
|
4
|
+
* matched after normalisation (camelCase split, `-`/`.`/space to `_`, lower-cased), so `x-api-key`,
|
|
5
|
+
* `privateKey`, `Set-Cookie` and `client_secret` are all the same kind of name.
|
|
6
|
+
*/
|
|
7
|
+
export declare const REDACTED = "[redacted]";
|
|
8
|
+
/** Bounds of the printed body: serialized bytes, per string, per array/object, nesting and the oversize preview. */
|
|
9
|
+
export declare const ERROR_BODY_LIMITS: {
|
|
10
|
+
readonly bytes: 16384;
|
|
11
|
+
readonly string: 2048;
|
|
12
|
+
readonly items: 100;
|
|
13
|
+
readonly depth: 8;
|
|
14
|
+
readonly preview: 4096;
|
|
15
|
+
};
|
|
16
|
+
/** True when a field of this name may hold a secret. */
|
|
17
|
+
export declare function secretField(key: string, value?: unknown): boolean;
|
|
18
|
+
/** True when a run of 12 to 19 digits passes the Luhn check and could be a card number (a `1` prefix only for 15-digit UATP cards, so ms timestamps stay readable). */
|
|
19
|
+
export declare function cardNumber(digits: string): boolean;
|
|
20
|
+
/** A value that looks random (letters and digits, no separators, 16 or more characters): an authorization code, never an error code. */
|
|
21
|
+
export declare const randomCode: (v: unknown) => boolean;
|
|
22
|
+
/** Redacts secret forms in free text: an error message, a raw body or a string field. Control and invisible characters are removed first. */
|
|
23
|
+
export declare function redactErrorText(text: string): string;
|
|
24
|
+
/** True when an object looks like an OAuth token or authorize answer (so `code` may be an authorization code). */
|
|
25
|
+
export declare const oauthShaped: (row: Record<string, unknown>) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* True when the `code` of this object may be an authorization code: an OAuth-shaped object, a `code` beside an
|
|
28
|
+
* OAuth error token (`{error: "invalid_grant", code}`), or a random-looking value. `errorBody` redacts that `code`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const authorizationCode: (row: Record<string, unknown>) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A redacted, bounded copy of an error body: secret-named fields (after key normalisation, glued names included),
|
|
33
|
+
* header pairs (`{name, value}` in any case, `[name, value]` tuples, flat `rawHeaders`, `Name: value` lines) and
|
|
34
|
+
* validation echoes of secret fields, OAuth authorization codes, card numbers (Luhn-checked) and other payment or
|
|
35
|
+
* personal data, Stripe client secrets, secret-shaped keys and values, and JSON nested in strings, escaped or not. A result still over 16 KiB serialized becomes `{truncated, bytes, preview}` of the redacted text.
|
|
36
|
+
*/
|
|
37
|
+
export declare function redactErrorBody(body: unknown): unknown;
|