@usearete/sdk 0.7.1 → 0.8.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/README.md +9 -5
- package/dist/index.cjs +56 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +31 -17
- package/dist/index.esm.js +56 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ Each packaged, attached, or standalone program is canonically available under `s
|
|
|
75
75
|
- `addresses` - semantic address derivations, when defined
|
|
76
76
|
- `accounts` - typed point reads for program accounts
|
|
77
77
|
- `queries` - program-level HTTP queries
|
|
78
|
+
- `read` - optional program-oriented convenience reads supplied by the SDK
|
|
78
79
|
- `raw` - exact IDL instruction builders with synchronous `.build(...)`
|
|
79
80
|
- `instructions` - semantic one-instruction operations with `.prepare(...)`
|
|
80
81
|
- `transactions` - semantic one-transaction operations with `.prepare(...)`
|
|
@@ -96,11 +97,14 @@ const client = await Arete.connect(LOCAL_STACK, {
|
|
|
96
97
|
});
|
|
97
98
|
```
|
|
98
99
|
|
|
99
|
-
Installed hosted SDKs instead
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
Installed hosted program SDKs instead carry a complete `hosted-binding`
|
|
101
|
+
descriptor opaquely inside the exported program cartridge. Passing that one
|
|
102
|
+
program object to `createSession` or `ConnectOptions.programs` automatically
|
|
103
|
+
activates its release-pinned account reads; consumers do not import or register
|
|
104
|
+
the descriptor separately. Hosted account reads ignore `httpUrl` and stack HTTP
|
|
105
|
+
endpoints. The advanced `programReads` override remains available, but it must
|
|
106
|
+
replace the complete descriptor; release, binding, and endpoint fields are never
|
|
107
|
+
patched independently.
|
|
104
108
|
|
|
105
109
|
Stack and program queries remain stack-HTTP operations. They continue to use
|
|
106
110
|
`httpUrl` or `stack.endpoints.http` and do not use a hosted Program Read binding.
|
package/dist/index.cjs
CHANGED
|
@@ -5295,6 +5295,31 @@ function createProgramPdas(pdas) {
|
|
|
5295
5295
|
return pdas;
|
|
5296
5296
|
}
|
|
5297
5297
|
|
|
5298
|
+
/** Opaque generated-program metadata used to carry its default read transport. */
|
|
5299
|
+
const PROGRAM_READ_DESCRIPTOR = Symbol.for('@usearete/sdk/program-read-descriptor');
|
|
5300
|
+
/**
|
|
5301
|
+
* Bundle a generated program definition with its default read descriptor.
|
|
5302
|
+
*
|
|
5303
|
+
* Generated SDK entries call this automatically. The descriptor is deliberately
|
|
5304
|
+
* non-enumerable so it remains an implementation detail of the program cartridge.
|
|
5305
|
+
*/
|
|
5306
|
+
function withProgramRead(program, descriptor) {
|
|
5307
|
+
const properties = Object.getOwnPropertyDescriptors(program);
|
|
5308
|
+
Reflect.deleteProperty(properties, PROGRAM_READ_DESCRIPTOR);
|
|
5309
|
+
const bundled = Object.create(Object.getPrototypeOf(program), properties);
|
|
5310
|
+
Object.defineProperty(bundled, PROGRAM_READ_DESCRIPTOR, {
|
|
5311
|
+
value: descriptor,
|
|
5312
|
+
enumerable: false,
|
|
5313
|
+
configurable: false,
|
|
5314
|
+
writable: false,
|
|
5315
|
+
});
|
|
5316
|
+
return bundled;
|
|
5317
|
+
}
|
|
5318
|
+
/** Resolve the default read descriptor carried by a generated program SDK. */
|
|
5319
|
+
function getProgramReadDescriptor(program) {
|
|
5320
|
+
return program?.[PROGRAM_READ_DESCRIPTOR];
|
|
5321
|
+
}
|
|
5322
|
+
|
|
5298
5323
|
const STACK_RUNTIME_EXTENSIONS = '__areteStackRuntimeExtensions';
|
|
5299
5324
|
const PROGRAM_OPERATION_EXTENSIONS = '__areteProgramOperationExtensions';
|
|
5300
5325
|
function defineProgramExtensions() {
|
|
@@ -5321,6 +5346,10 @@ function mergeOperations(base, extension) {
|
|
|
5321
5346
|
function extendProgram(program, extensions) {
|
|
5322
5347
|
const base = program;
|
|
5323
5348
|
const extended = { ...program };
|
|
5349
|
+
const readDescriptor = Object.getOwnPropertyDescriptor(program, PROGRAM_READ_DESCRIPTOR);
|
|
5350
|
+
if (readDescriptor) {
|
|
5351
|
+
Object.defineProperty(extended, PROGRAM_READ_DESCRIPTOR, readDescriptor);
|
|
5352
|
+
}
|
|
5324
5353
|
delete extended.sdkDefinitionHash;
|
|
5325
5354
|
for (const key of ['pdas', 'accounts', 'queries', 'addresses', 'constants', 'defaults', 'math']) {
|
|
5326
5355
|
const extensionValue = extensions[key];
|
|
@@ -5333,7 +5362,9 @@ function extendProgram(program, extensions) {
|
|
|
5333
5362
|
}
|
|
5334
5363
|
const baseFactory = base[PROGRAM_OPERATION_EXTENSIONS]?.createOperations;
|
|
5335
5364
|
const extensionFactory = extensions.createOperations;
|
|
5336
|
-
|
|
5365
|
+
const baseReadFactory = base[PROGRAM_OPERATION_EXTENSIONS]?.createRead;
|
|
5366
|
+
const extensionReadFactory = extensions.createRead;
|
|
5367
|
+
if (baseFactory || extensionFactory || baseReadFactory || extensionReadFactory) {
|
|
5337
5368
|
Object.defineProperty(extended, PROGRAM_OPERATION_EXTENSIONS, {
|
|
5338
5369
|
value: {
|
|
5339
5370
|
createOperations(context) {
|
|
@@ -5346,6 +5377,14 @@ function extendProgram(program, extensions) {
|
|
|
5346
5377
|
}
|
|
5347
5378
|
return mergeOperations(baseOperations, extensionFactory?.(context));
|
|
5348
5379
|
},
|
|
5380
|
+
createRead(context) {
|
|
5381
|
+
const baseRead = baseReadFactory?.(context);
|
|
5382
|
+
if (baseRead) {
|
|
5383
|
+
const connectedProgram = context.program;
|
|
5384
|
+
connectedProgram.read = mergeNamespace(connectedProgram.read, baseRead);
|
|
5385
|
+
}
|
|
5386
|
+
return mergeNamespace(baseRead, extensionReadFactory?.(context));
|
|
5387
|
+
},
|
|
5349
5388
|
},
|
|
5350
5389
|
enumerable: false,
|
|
5351
5390
|
configurable: false,
|
|
@@ -6151,7 +6190,9 @@ function createTransactionTransport(baseUrl, authenticatedFetch) {
|
|
|
6151
6190
|
}
|
|
6152
6191
|
|
|
6153
6192
|
function effectiveProgramRead(stack, name, override) {
|
|
6154
|
-
return override
|
|
6193
|
+
return override
|
|
6194
|
+
?? stack.programReads?.[name]
|
|
6195
|
+
?? getProgramReadDescriptor(stack.programs?.[name]);
|
|
6155
6196
|
}
|
|
6156
6197
|
function validateReleaseIdentity(programName, definition, release) {
|
|
6157
6198
|
if (release
|
|
@@ -6225,7 +6266,10 @@ function validateProgramReads(stack, overrides, validateDescriptorKeys = true) {
|
|
|
6225
6266
|
validateProgramReadDescriptor(key, overrides[key]);
|
|
6226
6267
|
}
|
|
6227
6268
|
for (const [name, definition] of Object.entries(stack.programs ?? {})) {
|
|
6228
|
-
|
|
6269
|
+
const bundled = getProgramReadDescriptor(definition);
|
|
6270
|
+
if (bundled)
|
|
6271
|
+
validateProgramReadDescriptor(name, bundled);
|
|
6272
|
+
validateReleaseIdentity(name, definition, effectiveProgramRead(stack, name, overrides?.[name])?.release);
|
|
6229
6273
|
validateReleaseIdentity(name, definition, overrides?.[name]?.release);
|
|
6230
6274
|
}
|
|
6231
6275
|
}
|
|
@@ -6415,18 +6459,21 @@ let Arete$1 = class Arete {
|
|
|
6415
6459
|
const base = bases[name];
|
|
6416
6460
|
const connectedProgram = {
|
|
6417
6461
|
...base,
|
|
6462
|
+
read: {},
|
|
6418
6463
|
instructions: {},
|
|
6419
6464
|
transactions: {},
|
|
6420
6465
|
flows: {},
|
|
6421
6466
|
};
|
|
6422
6467
|
const runtime = getProgramRuntimeExtensions(definition);
|
|
6423
|
-
const
|
|
6468
|
+
const context = {
|
|
6424
6469
|
chain: this._chain,
|
|
6425
6470
|
get wallet() {
|
|
6426
6471
|
return client._wallet;
|
|
6427
6472
|
},
|
|
6428
6473
|
program: connectedProgram,
|
|
6429
|
-
}
|
|
6474
|
+
};
|
|
6475
|
+
connectedProgram.read = runtime?.createRead?.(context) ?? {};
|
|
6476
|
+
const operations = runtime?.createOperations?.(context);
|
|
6430
6477
|
connectedProgram.instructions = operations?.instructions ?? {};
|
|
6431
6478
|
connectedProgram.transactions = operations?.transactions ?? {};
|
|
6432
6479
|
connectedProgram.flows = operations?.flows ?? {};
|
|
@@ -6866,7 +6913,9 @@ function resolveMemberConnectOptions(stack, member, options, forceHttpOnly) {
|
|
|
6866
6913
|
function validateCompositionProgramReads(stack, member, options) {
|
|
6867
6914
|
const overrides = resolveSessionProgramReads(stack, member, options);
|
|
6868
6915
|
for (const [name, program] of Object.entries(stack.programs ?? {})) {
|
|
6869
|
-
const descriptor = overrides?.[name]
|
|
6916
|
+
const descriptor = overrides?.[name]
|
|
6917
|
+
?? stack.programReads?.[name]
|
|
6918
|
+
?? getProgramReadDescriptor(program);
|
|
6870
6919
|
if (descriptor)
|
|
6871
6920
|
validateProgramReadDescriptor(name, descriptor);
|
|
6872
6921
|
if (Object.keys(program.accounts ?? {}).length === 0)
|
|
@@ -7464,5 +7513,6 @@ exports.unwrapOperationExecutionError = unwrapOperationExecutionError;
|
|
|
7464
7513
|
exports.validateAccountResolution = validateAccountResolution;
|
|
7465
7514
|
exports.validateProgramReadDescriptor = validateProgramReadDescriptor;
|
|
7466
7515
|
exports.validateSubscriptionId = validateSubscriptionId;
|
|
7516
|
+
exports.withProgramRead = withProgramRead;
|
|
7467
7517
|
exports.withPrograms = withPrograms;
|
|
7468
7518
|
//# sourceMappingURL=index.cjs.map
|