@antcde/connect-ts 0.4.27-rc.1 → 0.4.27-rc.10
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 +67 -3
- package/build/AntConnect.d.ts +2 -0
- package/build/AntConnect.d.ts.map +1 -1
- package/build/AntConnect.js +2 -0
- package/build/AntHttpClient.d.ts +0 -5
- package/build/AntHttpClient.d.ts.map +1 -1
- package/build/AntHttpClient.js +0 -5
- package/build/ai/index.d.ts +5 -0
- package/build/ai/index.d.ts.map +1 -0
- package/build/ai/index.js +3 -0
- package/build/ai/mutationDescriptors.d.ts +3 -0
- package/build/ai/mutationDescriptors.d.ts.map +1 -0
- package/build/ai/mutationDescriptors.js +207 -0
- package/build/ai/mutationTargets.d.ts +21 -0
- package/build/ai/mutationTargets.d.ts.map +1 -0
- package/build/ai/mutationTargets.js +72 -0
- package/build/ai/queryDescriptors.d.ts +3 -0
- package/build/ai/queryDescriptors.d.ts.map +1 -0
- package/build/ai/queryDescriptors.js +174 -0
- package/build/ai/types.d.ts +35 -0
- package/build/ai/types.d.ts.map +1 -0
- package/build/ai/types.js +1 -0
- package/build/comms/client.d.ts.map +1 -1
- package/build/comms/client.js +39 -41
- package/build/comms/connection.d.ts +32 -0
- package/build/comms/connection.d.ts.map +1 -0
- package/build/comms/connection.js +159 -0
- package/build/comms/handshake.d.ts +16 -0
- package/build/comms/handshake.d.ts.map +1 -0
- package/build/comms/handshake.js +73 -0
- package/build/comms/host.d.ts.map +1 -1
- package/build/comms/host.js +22 -26
- package/build/comms/hostAPI.js +1 -1
- package/build/comms/hostSlot.d.ts +23 -0
- package/build/comms/hostSlot.d.ts.map +1 -0
- package/build/comms/hostSlot.js +55 -0
- package/build/comms/models.d.ts +31 -2
- package/build/comms/models.d.ts.map +1 -1
- package/build/comms/signalTypes.d.ts +1 -1
- package/build/comms/signalTypes.d.ts.map +1 -1
- package/build/comms/transport.d.ts +18 -2
- package/build/comms/transport.d.ts.map +1 -1
- package/build/comms/transport.js +25 -10
- package/build/index.d.ts +4 -2
- package/build/index.d.ts.map +1 -1
- package/build/service-runtime.d.ts +4 -1
- package/build/service-runtime.d.ts.map +1 -1
- package/build/service-runtime.js +4 -1
- package/build/service-types-app.d.ts +1 -1
- package/build/service-types-app.d.ts.map +1 -1
- package/build/service-types.d.ts +2 -1
- package/build/service-types.d.ts.map +1 -1
- package/build/services/AiService.d.ts +18 -0
- package/build/services/AiService.d.ts.map +1 -0
- package/build/services/AiService.js +9 -0
- package/build/services/AppService/factory/categories.d.ts +30 -0
- package/build/services/AppService/factory/categories.d.ts.map +1 -0
- package/build/services/AppService/factory/categories.js +11 -0
- package/build/services/AppService/factory/resourceAccess.d.ts +21 -0
- package/build/services/AppService/factory/resourceAccess.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceAccess.js +49 -0
- package/build/services/AppService/factory/resourceAssignments.d.ts +66 -0
- package/build/services/AppService/factory/resourceAssignments.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceAssignments.js +12 -0
- package/build/services/AppService/factory/resourceChannels.d.ts +89 -0
- package/build/services/AppService/factory/resourceChannels.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceChannels.js +19 -0
- package/build/services/AppService/factory/resourceCommerce.d.ts +52 -0
- package/build/services/AppService/factory/resourceCommerce.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceCommerce.js +18 -0
- package/build/services/AppService/factory/resourceSnapshot.d.ts +75 -0
- package/build/services/AppService/factory/resourceSnapshot.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceSnapshot.js +55 -0
- package/build/services/AppService/factory/resourceUploads.d.ts +37 -0
- package/build/services/AppService/factory/resourceUploads.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceUploads.js +8 -0
- package/build/services/AppService/factory/resources.d.ts +167 -0
- package/build/services/AppService/factory/resources.d.ts.map +1 -0
- package/build/services/AppService/factory/resources.js +45 -0
- package/build/services/AppService/factory/taxonomy.d.ts +25 -0
- package/build/services/AppService/factory/taxonomy.d.ts.map +1 -0
- package/build/services/AppService/factory/taxonomy.js +5 -0
- package/build/services/AppService/index.d.ts +5 -5
- package/build/services/AppService/index.d.ts.map +1 -1
- package/build/services/AppService/index.js +13 -8
- package/build/services/AppService/types/appCategories.d.ts +28 -0
- package/build/services/AppService/types/appCategories.d.ts.map +1 -1
- package/build/services/AppService/types/appList.d.ts +28 -0
- package/build/services/AppService/types/appList.d.ts.map +1 -1
- package/build/services/AppService/types/appManifest.d.ts +46 -0
- package/build/services/AppService/types/appManifest.d.ts.map +1 -1
- package/build/services/AppService/types/appRequests.d.ts +13 -0
- package/build/services/AppService/types/appRequests.d.ts.map +1 -1
- package/build/services/AppService/types/resourceAssignments.d.ts +38 -0
- package/build/services/AppService/types/resourceAssignments.d.ts.map +1 -0
- package/build/services/AppService/types/resourceAssignments.js +10 -0
- package/build/services/AppService/types/resourceEntitlements.d.ts +118 -0
- package/build/services/AppService/types/resourceEntitlements.d.ts.map +1 -0
- package/build/services/AppService/types/resourceEntitlements.js +1 -0
- package/build/services/AppService/types/resourceReleases.d.ts +230 -0
- package/build/services/AppService/types/resourceReleases.d.ts.map +1 -0
- package/build/services/AppService/types/resourceReleases.js +1 -0
- package/build/services/AppService/types/resourceRequests.d.ts +115 -0
- package/build/services/AppService/types/resourceRequests.d.ts.map +1 -0
- package/build/services/AppService/types/resourceRequests.js +1 -0
- package/build/services/AppService/types/sellableResources.d.ts +231 -0
- package/build/services/AppService/types/sellableResources.d.ts.map +1 -0
- package/build/services/AppService/types/sellableResources.js +1 -0
- package/build/services/AppService/types/snapshotFileSource.d.ts +110 -0
- package/build/services/AppService/types/snapshotFileSource.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotFileSource.js +8 -0
- package/build/services/AppService/types/snapshotPayload.d.ts +166 -0
- package/build/services/AppService/types/snapshotPayload.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotPayload.js +19 -0
- package/build/services/AppService/types/snapshotSources.d.ts +116 -0
- package/build/services/AppService/types/snapshotSources.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotSources.js +7 -0
- package/build/services/AppService/types/snapshotUploads.d.ts +109 -0
- package/build/services/AppService/types/snapshotUploads.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotUploads.js +20 -0
- package/build/services/AppService/types/taxonomy.d.ts +76 -0
- package/build/services/AppService/types/taxonomy.d.ts.map +1 -0
- package/build/services/AppService/types/taxonomy.js +1 -0
- package/build/services/AppService/types.d.ts +10 -0
- package/build/services/AppService/types.d.ts.map +1 -1
- package/build/services/AppService/types.js +10 -0
- package/build/services/DmsService.d.ts +2 -160
- package/build/services/DmsService.d.ts.map +1 -1
- package/build/services/DmsService.types.d.ts +169 -0
- package/build/services/DmsService.types.d.ts.map +1 -0
- package/build/services/DmsService.types.js +1 -0
- package/build/services/ProjectService.d.ts +20 -0
- package/build/services/ProjectService.d.ts.map +1 -1
- package/build/services/ProjectService.js +1 -0
- package/build/services/TaskService.requests.d.ts +61 -0
- package/build/services/TaskService.requests.d.ts.map +1 -0
- package/build/services/TaskService.requests.js +1 -0
- package/build/services/TaskService.types.d.ts +2 -51
- package/build/services/TaskService.types.d.ts.map +1 -1
- package/build/services/TokenService.d.ts +0 -1
- package/build/services/TokenService.d.ts.map +1 -1
- package/build/services/TokenService.js +0 -2
- package/build/services/UserService.d.ts +3 -0
- package/build/services/UserService.d.ts.map +1 -1
- package/build/services/Webhook/EventService.d.ts +7 -0
- package/build/services/Webhook/EventService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerService.d.ts +80 -0
- package/build/services/Webhook/TriggerService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerService.js +15 -0
- package/build/services/Websockets/StoreEvents.d.ts +14 -1
- package/build/services/Websockets/StoreEvents.d.ts.map +1 -1
- package/build/services/userPreferences.d.ts +47 -0
- package/build/services/userPreferences.d.ts.map +1 -0
- package/build/services/userPreferences.js +42 -0
- package/package.json +7 -6
- package/schemas/app-config.schema.json +79 -8
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime helpers for narrowing an access-layer refusal (AAD-898).
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `factory/resources.ts` because these are values, not part of the
|
|
5
|
+
* factory — and because branching on `reason` is something every caller does,
|
|
6
|
+
* not only the one that made the request. Both are re-exported from the package
|
|
7
|
+
* root via `service-runtime.ts`.
|
|
8
|
+
*/
|
|
9
|
+
/** Every refusal reason the access layer can return. */
|
|
10
|
+
export const RESOURCE_ACCESS_REASONS = [
|
|
11
|
+
'not_entitled',
|
|
12
|
+
'entitlement_revoked',
|
|
13
|
+
'subscription_expired',
|
|
14
|
+
'subscription_pending_approval',
|
|
15
|
+
// AAD-949. Reachable ONLY by a license that holds a live entitlement, because
|
|
16
|
+
// the entitlement checks run first — so the remedy is "ask the publisher to add
|
|
17
|
+
// you to that channel", never "buy this". Do not collapse it into
|
|
18
|
+
// `not_entitled`: the two are answered by different people.
|
|
19
|
+
'channel_not_accessible',
|
|
20
|
+
// AAD-954. The only reason about a PERSON rather than a license, and checked
|
|
21
|
+
// last — so it is reachable only inside a license that genuinely bought the
|
|
22
|
+
// resource on a track it may use. The remedy is always "ask your license
|
|
23
|
+
// admin", never "buy this".
|
|
24
|
+
'not_granted',
|
|
25
|
+
'version_withdrawn',
|
|
26
|
+
'version_not_ready',
|
|
27
|
+
'payload_backend_not_implemented',
|
|
28
|
+
];
|
|
29
|
+
const _reasonsMatchTheUnion = true;
|
|
30
|
+
void _reasonsMatchTheUnion;
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return typeof value === 'object' && value !== null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Narrow an unknown error (typically an axios rejection) to an access-layer
|
|
36
|
+
* refusal, so the caller can branch on `reason` rather than on the status code.
|
|
37
|
+
*/
|
|
38
|
+
export function isResourceAccessError(error) {
|
|
39
|
+
const response = isRecord(error) ? error.response : undefined;
|
|
40
|
+
const data = isRecord(response) ? response.data : undefined;
|
|
41
|
+
if (!isRecord(data))
|
|
42
|
+
return false;
|
|
43
|
+
// `message` is checked as well as `reason`: the predicate asserts the full
|
|
44
|
+
// `ResourceAccessError` shape, and a guard that narrows to a field it never
|
|
45
|
+
// verified is how a `message.length` somewhere downstream becomes a crash.
|
|
46
|
+
return typeof data.message === 'string'
|
|
47
|
+
&& typeof data.reason === 'string'
|
|
48
|
+
&& RESOURCE_ACCESS_REASONS.includes(data.reason);
|
|
49
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ResourceAssignments } from '../types';
|
|
2
|
+
import type { AntHttpClient } from "../../../AntHttpClient";
|
|
3
|
+
import type { DataWrapper } from "../../../types";
|
|
4
|
+
/**
|
|
5
|
+
* Who inside the BUYING license may use a resource that license bought
|
|
6
|
+
* (AAD-954).
|
|
7
|
+
*
|
|
8
|
+
* The buyer-side counterpart of `factory/assignments.ts`'s license-scope half,
|
|
9
|
+
* and deliberately the same vocabulary, so the admin mental model carries over
|
|
10
|
+
* from an installed app unchanged.
|
|
11
|
+
*
|
|
12
|
+
* **The default on purchase is CLOSED** — license admins can read immediately,
|
|
13
|
+
* nobody else until granted. This matches the app store: a purchased thing opens
|
|
14
|
+
* closed there too (the only automatic "everyone" grant is for first-party
|
|
15
|
+
* always-available apps, never a purchase). It matters more for a resource: an
|
|
16
|
+
* app mediates what it shows, a resource returns its dataset wholesale, and a
|
|
17
|
+
* disclosure cannot be undone while opening up is one click.
|
|
18
|
+
*
|
|
19
|
+
* **Three differences from the app equivalent, all deliberate:**
|
|
20
|
+
*
|
|
21
|
+
* 1. **No `channelIds` argument anywhere.** A resource entitlement pins one
|
|
22
|
+
* channel and one version for the whole license, so every user necessarily
|
|
23
|
+
* reads the same build. Do not add a channel picker to this screen — there is
|
|
24
|
+
* nothing for it to change.
|
|
25
|
+
* 2. **No `licenseId` argument.** The entitlement is unique per license and the
|
|
26
|
+
* acting license comes from the session header, so there is nothing to pass.
|
|
27
|
+
* 3. **No project scope.** Resources are not installed into projects, so the
|
|
28
|
+
* license/project switch the app screen has does not belong here.
|
|
29
|
+
*
|
|
30
|
+
* Every method is license-admin-only (403 otherwise) and returns the FULL
|
|
31
|
+
* picture after the change, so there is never a follow-up refetch.
|
|
32
|
+
*
|
|
33
|
+
* Granting is not the only gate. A read also needs the license to hold a live
|
|
34
|
+
* entitlement and to be allowed to draw from its channel; those fail with
|
|
35
|
+
* `not_entitled` / `subscription_expired` / `channel_not_accessible` instead.
|
|
36
|
+
* A missing grant is specifically `not_granted`, which always means *ask your
|
|
37
|
+
* license admin* and never *buy it* — see `RESOURCE_ACCESS_REASONS`.
|
|
38
|
+
*/
|
|
39
|
+
export interface ResourceAssignmentFactory {
|
|
40
|
+
/**
|
|
41
|
+
* The current access picture: who is assigned, who always has access, and
|
|
42
|
+
* which roles could still be added.
|
|
43
|
+
*
|
|
44
|
+
* 404 when the calling license holds no entitlement to this resource — from
|
|
45
|
+
* the buyer's side there is nothing there to be forbidden from.
|
|
46
|
+
*/
|
|
47
|
+
fetchResourceAssignments: (resourceId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
48
|
+
/** Open the resource to every member of the license. */
|
|
49
|
+
setResourceEveryone: (resourceId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
50
|
+
/** Close it again, back to whoever holds an explicit grant (admins keep access). */
|
|
51
|
+
clearResourceEveryone: (resourceId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
52
|
+
/** Idempotent. 400 if the role belongs to another license. */
|
|
53
|
+
assignResourceRole: (resourceId: string, roleId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
54
|
+
/** Idempotent — removing a role that was never assigned is a no-op, not an error. */
|
|
55
|
+
unassignResourceRole: (resourceId: string, roleId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
56
|
+
/**
|
|
57
|
+
* Idempotent. 404 if the user is not a member of the license — a grant on a
|
|
58
|
+
* non-member could never satisfy a read, so accepting it would be a lie this
|
|
59
|
+
* screen then displays as access.
|
|
60
|
+
*/
|
|
61
|
+
assignResourceUser: (resourceId: string, userId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
62
|
+
/** Idempotent. */
|
|
63
|
+
unassignResourceUser: (resourceId: string, userId: string) => Promise<DataWrapper<ResourceAssignments>>;
|
|
64
|
+
}
|
|
65
|
+
export declare function newResourceAssignmentFactory(client: AntHttpClient): ResourceAssignmentFactory;
|
|
66
|
+
//# sourceMappingURL=resourceAssignments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceAssignments.d.ts","sourceRoot":"","sources":["../../../../src/services/AppService/factory/resourceAssignments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,+BAAuB;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAe;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;OAMG;IACH,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE3F,wDAAwD;IACxD,mBAAmB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IACtF,oFAAoF;IACpF,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAExF,8DAA8D;IAC9D,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IACrG,qFAAqF;IACrF,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAEvG;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IACrG,kBAAkB;IAClB,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;CACxG;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,aAAa,GAAG,yBAAyB,CAe7F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function newResourceAssignmentFactory(client) {
|
|
2
|
+
const base = (resourceId) => `/store/resources/${resourceId}/entitlement/assignments`;
|
|
3
|
+
return {
|
|
4
|
+
fetchResourceAssignments: resourceId => client.get(base(resourceId)),
|
|
5
|
+
setResourceEveryone: resourceId => client.post(`${base(resourceId)}/everyone`),
|
|
6
|
+
clearResourceEveryone: resourceId => client.delete(`${base(resourceId)}/everyone`),
|
|
7
|
+
assignResourceRole: (resourceId, roleId) => client.post(`${base(resourceId)}/roles/${roleId}`),
|
|
8
|
+
unassignResourceRole: (resourceId, roleId) => client.delete(`${base(resourceId)}/roles/${roleId}`),
|
|
9
|
+
assignResourceUser: (resourceId, userId) => client.post(`${base(resourceId)}/users/${userId}`),
|
|
10
|
+
unassignResourceUser: (resourceId, userId) => client.delete(`${base(resourceId)}/users/${userId}`),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { CreateResourceChannelData, ResourceChannel, ResourceChannelMember, ResourceUnpublishImpact, UpdateResourceChannelData } from '../types';
|
|
2
|
+
import type { MessageResponse } from "../../../AntConnect";
|
|
3
|
+
import type { AntHttpClient } from "../../../AntHttpClient";
|
|
4
|
+
import type { DataWrapper } from "../../../types";
|
|
5
|
+
/**
|
|
6
|
+
* Resource release channels and the licenses allowed to draw from them
|
|
7
|
+
* (AAD-898, access modes AAD-949).
|
|
8
|
+
*
|
|
9
|
+
* Split out of `factory/resources.ts` for size and folded back into
|
|
10
|
+
* `SellableResourceFactory` there, so the public surface is unchanged — this
|
|
11
|
+
* mirrors how `factory/channels.ts` sits under `AppService`.
|
|
12
|
+
*
|
|
13
|
+
* **The mental model differs from the app store's in one place that matters.**
|
|
14
|
+
* On an app, membership of a `specific_licenses` channel is itself a way to be
|
|
15
|
+
* entitled. On a resource it is NOT: entitlement always comes from a purchase,
|
|
16
|
+
* and `access_mode` only narrows which entitled licenses may draw from a track.
|
|
17
|
+
* Adding a license to a channel therefore gives it nothing it did not already
|
|
18
|
+
* have — do not build an "grant access by adding to a channel" affordance.
|
|
19
|
+
*/
|
|
20
|
+
export interface ResourceChannelFactory {
|
|
21
|
+
/**
|
|
22
|
+
* List channels.
|
|
23
|
+
*
|
|
24
|
+
* Scoped to the viewer server-side: a publisher gets every channel with
|
|
25
|
+
* `member_count`, a buyer gets only channels their license may draw from, with
|
|
26
|
+
* `member_count: null`. A restricted channel simply does not appear for a
|
|
27
|
+
* non-member, so an empty list is a legitimate state, not an error.
|
|
28
|
+
*/
|
|
29
|
+
fetchResourceChannels: (resourceId: string) => Promise<DataWrapper<ResourceChannel[]>>;
|
|
30
|
+
createResourceChannel: (resourceId: string, data: CreateResourceChannelData) => Promise<DataWrapper<ResourceChannel>>;
|
|
31
|
+
/**
|
|
32
|
+
* Partial update — send only the keys you are changing.
|
|
33
|
+
*
|
|
34
|
+
* Promoting a channel with `is_default: true` demotes the previous default
|
|
35
|
+
* atomically; UNSETTING the current default is refused with a 400, because a
|
|
36
|
+
* resource must always have exactly one.
|
|
37
|
+
*/
|
|
38
|
+
updateResourceChannel: (resourceId: string, channelId: string, data: UpdateResourceChannelData) => Promise<DataWrapper<ResourceChannel>>;
|
|
39
|
+
/** Refused (400) for the default channel, and for a channel that still has members. */
|
|
40
|
+
deleteResourceChannel: (resourceId: string, channelId: string) => Promise<MessageResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Make a version live.
|
|
43
|
+
*
|
|
44
|
+
* Publishing FORWARD supersedes and moves nobody — existing buyers stay on
|
|
45
|
+
* their pin and simply gain an available update. Publishing an OLDER version
|
|
46
|
+
* is a rollback: buyers stranded ahead of it are force-moved down onto it,
|
|
47
|
+
* regardless of their `auto_update` setting. 422 if the version's payload is
|
|
48
|
+
* not `ready`.
|
|
49
|
+
*/
|
|
50
|
+
publishResourceVersion: (resourceId: string, channelId: string, versionId: string) => Promise<DataWrapper<ResourceChannel>>;
|
|
51
|
+
/**
|
|
52
|
+
* Unrelease: clear the channel's active version AND withdraw every holder
|
|
53
|
+
* drawing from it. Synchronous — the pulled build stops being served
|
|
54
|
+
* immediately. Nobody is exempt, the publisher included.
|
|
55
|
+
*
|
|
56
|
+
* Also the required first step before deleting a version this channel serves:
|
|
57
|
+
* that delete is refused with a 409 rather than performing this silently.
|
|
58
|
+
*/
|
|
59
|
+
unpublishResourceChannel: (resourceId: string, channelId: string) => Promise<{
|
|
60
|
+
message: string;
|
|
61
|
+
data: {
|
|
62
|
+
withdrawn: {
|
|
63
|
+
entitlements: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
/** Who an unpublish would cut off — show this before confirming. */
|
|
68
|
+
fetchResourceUnpublishImpact: (resourceId: string, channelId: string) => Promise<DataWrapper<ResourceUnpublishImpact>>;
|
|
69
|
+
/** Paginated. Publisher-only; a buyer gets 403 even for a channel they are on. */
|
|
70
|
+
fetchResourceChannelMembers: (resourceId: string, channelId: string, params?: {
|
|
71
|
+
page?: number;
|
|
72
|
+
per_page?: number;
|
|
73
|
+
}) => Promise<DataWrapper<ResourceChannelMember[]>>;
|
|
74
|
+
/**
|
|
75
|
+
* Add a license by UUID. 400 if it is already a member.
|
|
76
|
+
*
|
|
77
|
+
* There is deliberately no endpoint that enumerates licenses, so this is a
|
|
78
|
+
* paste-a-UUID flow exactly as on the app side.
|
|
79
|
+
*/
|
|
80
|
+
addResourceChannelMember: (resourceId: string, channelId: string, licenseId: string) => Promise<DataWrapper<ResourceChannelMember>>;
|
|
81
|
+
/**
|
|
82
|
+
* Remove a license. Takes effect immediately — the backend flushes its decision
|
|
83
|
+
* cache, so the next read from that license is refused rather than served for
|
|
84
|
+
* the rest of the TTL.
|
|
85
|
+
*/
|
|
86
|
+
removeResourceChannelMember: (resourceId: string, channelId: string, licenseId: string) => Promise<MessageResponse>;
|
|
87
|
+
}
|
|
88
|
+
export declare function newResourceChannelFactory(client: AntHttpClient): ResourceChannelFactory;
|
|
89
|
+
//# sourceMappingURL=resourceChannels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceChannels.d.ts","sourceRoot":"","sources":["../../../../src/services/AppService/factory/resourceChannels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,4BAAoB;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,+BAAuB;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAe;AAG1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC,CAAA;IACtF,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,KAAK,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IACrH;;;;;;OAMG;IACH,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,KAAK,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IACxI,uFAAuF;IACvF,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1F;;;;;;;;OAQG;IACH,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IAC3H;;;;;;;OAOG;IACH,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,SAAS,EAAE;gBAAE,YAAY,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC,CAAA;IAChJ,oEAAoE;IACpE,4BAA4B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAAA;IAGtH,kFAAkF;IAClF,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAA;IACpK;;;;;OAKG;IACH,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAA;IACnI;;;;OAIG;IACH,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;CACpH;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,aAAa,GAAG,sBAAsB,CAyBvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import qs from 'qs';
|
|
2
|
+
export function newResourceChannelFactory(client) {
|
|
3
|
+
const base = (resourceId) => `/store/resources/${resourceId}/channels`;
|
|
4
|
+
return {
|
|
5
|
+
fetchResourceChannels: resourceId => client.get(base(resourceId)),
|
|
6
|
+
createResourceChannel: (resourceId, data) => client.post(base(resourceId), data),
|
|
7
|
+
updateResourceChannel: (resourceId, channelId, data) => client.put(`${base(resourceId)}/${channelId}`, data),
|
|
8
|
+
deleteResourceChannel: (resourceId, channelId) => client.delete(`${base(resourceId)}/${channelId}`),
|
|
9
|
+
publishResourceVersion: (resourceId, channelId, versionId) => client.post(`${base(resourceId)}/${channelId}/publish`, { version_id: versionId }),
|
|
10
|
+
unpublishResourceChannel: (resourceId, channelId) => client.delete(`${base(resourceId)}/${channelId}/active-version`),
|
|
11
|
+
fetchResourceUnpublishImpact: (resourceId, channelId) => client.get(`${base(resourceId)}/${channelId}/unpublish-impact`),
|
|
12
|
+
fetchResourceChannelMembers: (resourceId, channelId, params = {}) => {
|
|
13
|
+
const queryString = qs.stringify(params, { skipNulls: true });
|
|
14
|
+
return client.get(`${base(resourceId)}/${channelId}/members${queryString ? `?${queryString}` : ''}`);
|
|
15
|
+
},
|
|
16
|
+
addResourceChannelMember: (resourceId, channelId, licenseId) => client.post(`${base(resourceId)}/${channelId}/members`, { license_id: licenseId }),
|
|
17
|
+
removeResourceChannelMember: (resourceId, channelId, licenseId) => client.delete(`${base(resourceId)}/${channelId}/members/${licenseId}`),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AcquireResourceData, ResourceEntitlementSummary, ResourceSubscription } from '../types';
|
|
2
|
+
import type { CreatePricingTierData, PricingTier, UpdatePricingTierData } from '../types/pricingTiers';
|
|
3
|
+
import type { MessageResponse } from "../../../AntConnect";
|
|
4
|
+
import type { AntHttpClient } from "../../../AntHttpClient";
|
|
5
|
+
import type { DataWrapper } from "../../../types";
|
|
6
|
+
/**
|
|
7
|
+
* Pricing and purchase for sellable resources (AAD-898).
|
|
8
|
+
*
|
|
9
|
+
* Split out of `resources.ts` for file size when AAD-939 landed, along the same
|
|
10
|
+
* seam the backend already uses: commerce is REUSED from apps (`pricing_tiers` and
|
|
11
|
+
* `subscriptions` are polymorphic), whereas the rest of `resources.ts` is
|
|
12
|
+
* resource-specific. Folded into `SellableResourceFactory`, so callers still reach
|
|
13
|
+
* everything as `c.apps.*` and the public surface is unchanged.
|
|
14
|
+
*
|
|
15
|
+
* Money is handled offline: there is no payment processor, and a paid purchase is
|
|
16
|
+
* approval-gated by the publisher.
|
|
17
|
+
*/
|
|
18
|
+
export interface ResourceCommerceFactory {
|
|
19
|
+
/** Storefront-public: a prospective buyer may read these. */
|
|
20
|
+
fetchResourcePricingTiers: (resourceId: string) => Promise<DataWrapper<PricingTier[]>>;
|
|
21
|
+
/**
|
|
22
|
+
* Free and flat only. A seat tier is rejected with 422 on `errors.pricing_model`
|
|
23
|
+
* — resource entitlements are license-level and seats do not exist for them.
|
|
24
|
+
* Sending `seat_based: true` is rejected the same way.
|
|
25
|
+
*/
|
|
26
|
+
createResourcePricingTier: (resourceId: string, data: CreatePricingTierData) => Promise<DataWrapper<PricingTier>>;
|
|
27
|
+
updateResourcePricingTier: (resourceId: string, tierId: string, data: UpdatePricingTierData) => Promise<DataWrapper<PricingTier>>;
|
|
28
|
+
deleteResourcePricingTier: (resourceId: string, tierId: string) => Promise<MessageResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Acquire the resource.
|
|
31
|
+
*
|
|
32
|
+
* FREE resource: omit `pricing_tier_id`; you get an entitlement immediately.
|
|
33
|
+
* SUBSCRIPTION resource: pass the tier; you get a `pending_approval`
|
|
34
|
+
* subscription that grants NO access until the publisher approves it.
|
|
35
|
+
*/
|
|
36
|
+
acquireResource: (resourceId: string, data?: AcquireResourceData) => Promise<DataWrapper<ResourceSubscription | ResourceEntitlementSummary>>;
|
|
37
|
+
fetchCurrentResourceSubscription: (resourceId: string) => Promise<DataWrapper<ResourceSubscription | null>>;
|
|
38
|
+
/** Publisher approval inbox. */
|
|
39
|
+
fetchPendingResourceSubscriptions: (resourceId: string) => Promise<DataWrapper<ResourceSubscription[]>>;
|
|
40
|
+
/** Publisher: every subscription on this resource. */
|
|
41
|
+
fetchResourceSubscriptions: (resourceId: string) => Promise<DataWrapper<ResourceSubscription[]>>;
|
|
42
|
+
/** Publisher: approving is what creates the entitlement and unlocks reads. */
|
|
43
|
+
approveResourceSubscription: (resourceId: string, subscriptionId: string) => Promise<DataWrapper<ResourceSubscription>>;
|
|
44
|
+
denyResourceSubscription: (resourceId: string, subscriptionId: string) => Promise<DataWrapper<ResourceSubscription>>;
|
|
45
|
+
cancelResourceSubscription: (resourceId: string, subscriptionId: string) => Promise<DataWrapper<ResourceSubscription>>;
|
|
46
|
+
reactivateResourceSubscription: (resourceId: string, subscriptionId: string) => Promise<DataWrapper<ResourceSubscription>>;
|
|
47
|
+
confirmResourceRenewal: (resourceId: string, subscriptionId: string, data?: {
|
|
48
|
+
external_payment_ref?: string;
|
|
49
|
+
}) => Promise<DataWrapper<ResourceSubscription>>;
|
|
50
|
+
}
|
|
51
|
+
export declare function newResourceCommerceFactory(client: AntHttpClient): ResourceCommerceFactory;
|
|
52
|
+
//# sourceMappingURL=resourceCommerce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceCommerce.d.ts","sourceRoot":"","sources":["../../../../src/services/AppService/factory/resourceCommerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrG,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,4BAAoB;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,+BAAuB;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAe;AAE1C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,uBAAuB;IAEtC,6DAA6D;IAC7D,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IACtF;;;;OAIG;IACH,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IACjH,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IACjI,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;IAG3F;;;;;;OAMG;IACH,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,GAAG,0BAA0B,CAAC,CAAC,CAAA;IAC5I,gCAAgC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC,CAAA;IAC3G,gCAAgC;IAChC,iCAAiC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;IACvG,sDAAsD;IACtD,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;IAChG,8EAA8E;IAC9E,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACvH,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACpH,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACtH,8BAA8B,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAC1H,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;CAC7J;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,uBAAuB,CAwBzF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function newResourceCommerceFactory(client) {
|
|
2
|
+
const base = (resourceId) => `/store/resources/${resourceId}`;
|
|
3
|
+
return {
|
|
4
|
+
fetchResourcePricingTiers: resourceId => client.get(`${base(resourceId)}/pricing-tiers`),
|
|
5
|
+
createResourcePricingTier: (resourceId, data) => client.post(`${base(resourceId)}/pricing-tiers`, data),
|
|
6
|
+
updateResourcePricingTier: (resourceId, tierId, data) => client.put(`${base(resourceId)}/pricing-tiers/${tierId}`, data),
|
|
7
|
+
deleteResourcePricingTier: (resourceId, tierId) => client.delete(`${base(resourceId)}/pricing-tiers/${tierId}`),
|
|
8
|
+
acquireResource: (resourceId, data = {}) => client.post(`${base(resourceId)}/subscriptions`, data),
|
|
9
|
+
fetchCurrentResourceSubscription: resourceId => client.get(`${base(resourceId)}/subscriptions/current`),
|
|
10
|
+
fetchPendingResourceSubscriptions: resourceId => client.get(`${base(resourceId)}/subscriptions/pending`),
|
|
11
|
+
fetchResourceSubscriptions: resourceId => client.get(`${base(resourceId)}/subscriptions`),
|
|
12
|
+
approveResourceSubscription: (resourceId, subscriptionId) => client.post(`${base(resourceId)}/subscriptions/${subscriptionId}/approve`),
|
|
13
|
+
denyResourceSubscription: (resourceId, subscriptionId) => client.post(`${base(resourceId)}/subscriptions/${subscriptionId}/deny`),
|
|
14
|
+
cancelResourceSubscription: (resourceId, subscriptionId) => client.post(`${base(resourceId)}/subscriptions/${subscriptionId}/cancel`),
|
|
15
|
+
reactivateResourceSubscription: (resourceId, subscriptionId) => client.post(`${base(resourceId)}/subscriptions/${subscriptionId}/reactivate`),
|
|
16
|
+
confirmResourceRenewal: (resourceId, subscriptionId, data = {}) => client.post(`${base(resourceId)}/subscriptions/${subscriptionId}/confirm-renewal`, data),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { SnapshotPayloadConfig, SnapshotPayloadSchema, SnapshotPreview } from '../types/snapshotPayload';
|
|
2
|
+
import type { SnapshotSource } from '../types/snapshotSources';
|
|
3
|
+
import type { AntHttpClient } from "../../../AntHttpClient";
|
|
4
|
+
import type { DataWrapper } from "../../../types";
|
|
5
|
+
/**
|
|
6
|
+
* Snapshot payloads (AAD-939) — publishing a dataset from a linked table.
|
|
7
|
+
*
|
|
8
|
+
* Split out of `resources.ts` for file size; folded into `SellableResourceFactory`
|
|
9
|
+
* so callers still reach everything as `c.apps.*` and the public surface is
|
|
10
|
+
* unchanged.
|
|
11
|
+
*
|
|
12
|
+
* **The publish flow is: preview → create → POLL → publish.** Skipping the poll is
|
|
13
|
+
* the mistake this whole contract is shaped to prevent — see
|
|
14
|
+
* `createResourceVersion` in `resources.ts`.
|
|
15
|
+
*/
|
|
16
|
+
export interface ResourceSnapshotFactory {
|
|
17
|
+
/**
|
|
18
|
+
* The tables this publisher can build a dataset from.
|
|
19
|
+
*
|
|
20
|
+
* Use this for the source picker rather than the generic table listing: that one
|
|
21
|
+
* carries no project attribution (so same-named tables in different projects are
|
|
22
|
+
* indistinguishable), no row count, and no publishable-column count — filling
|
|
23
|
+
* those in from it meant one request per table.
|
|
24
|
+
*
|
|
25
|
+
* Rows with `is_publishable: false` have nothing publishable in them. Show them
|
|
26
|
+
* disabled rather than filtering them out, so a publisher looking for a table they
|
|
27
|
+
* know exists finds it and learns why it cannot be used.
|
|
28
|
+
*
|
|
29
|
+
* The set returned is exactly the set `createResourceVersion` will accept, so the
|
|
30
|
+
* picker can never offer a table the create then refuses. 404 on a resource whose
|
|
31
|
+
* `payload_type` is not `snapshot`.
|
|
32
|
+
*/
|
|
33
|
+
fetchSnapshotSources: (resourceId: string, requestConfig?: Record<string, any>) => Promise<DataWrapper<SnapshotSource[]>>;
|
|
34
|
+
/**
|
|
35
|
+
* Dry-run a column selection before creating a version from it.
|
|
36
|
+
*
|
|
37
|
+
* Returns the row count, an estimated size, the ceilings, the declared schema and
|
|
38
|
+
* a truncated sample. Publisher-only; 404 on a resource whose `payload_type` is
|
|
39
|
+
* not `snapshot`.
|
|
40
|
+
*
|
|
41
|
+
* **Show `exceeds_limits` before letting the publisher continue.** Above either
|
|
42
|
+
* ceiling the backend REFUSES the version rather than truncating it — a partial
|
|
43
|
+
* dataset is indistinguishable from a complete one once published — so a
|
|
44
|
+
* publisher who is not warned here meets a wall at the last step instead.
|
|
45
|
+
*
|
|
46
|
+
* Unlike creating a version, this does NOT require the personal-data declaration:
|
|
47
|
+
* the publisher is still assembling a selection.
|
|
48
|
+
*/
|
|
49
|
+
previewResourceSnapshot: (resourceId: string, payloadConfig: Omit<SnapshotPayloadConfig, 'declarations'> & Partial<Pick<SnapshotPayloadConfig, 'declarations'>>, requestConfig?: Record<string, any>) => Promise<DataWrapper<SnapshotPreview>>;
|
|
50
|
+
}
|
|
51
|
+
export declare function newResourceSnapshotFactory(client: AntHttpClient): ResourceSnapshotFactory;
|
|
52
|
+
/**
|
|
53
|
+
* Narrow a version's `payload_schema` to a snapshot schema.
|
|
54
|
+
*
|
|
55
|
+
* `ResourceVersion.payload_schema` is typed for snapshots because they are the only
|
|
56
|
+
* payload type that records one today, but AAD-899 may store a different shape — so
|
|
57
|
+
* a component rendering the field list should narrow rather than assume. Use this
|
|
58
|
+
* instead of a cast: `as` would happily assert a shape that is not there, and the
|
|
59
|
+
* crash lands in whichever component reads `fields` first.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isSnapshotPayloadSchema(value: unknown): value is SnapshotPayloadSchema;
|
|
62
|
+
/**
|
|
63
|
+
* Narrow a version's source, or a schema's, to the FILE variant (AAD-948).
|
|
64
|
+
*
|
|
65
|
+
* A runtime guard rather than a cast, because the discriminator is optional on the
|
|
66
|
+
* table half — `source.type` is absent for every version written before AAD-948 and
|
|
67
|
+
* for every table-sourced version since. `value.type === 'file'` is the only safe
|
|
68
|
+
* test, and putting it here means no call site has to remember that.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isFileSnapshotSource(value: unknown): value is {
|
|
71
|
+
type: 'file';
|
|
72
|
+
upload_id: string;
|
|
73
|
+
sha256: string | null;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=resourceSnapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceSnapshot.d.ts","sourceRoot":"","sources":["../../../../src/services/AppService/factory/resourceSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,+BAAuB;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAe;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IAEzH;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,EAAE,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC,EACjH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAChC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;CAC3C;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,uBAAuB,CAQzF;AAMD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAgBtF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAYrE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export function newResourceSnapshotFactory(client) {
|
|
2
|
+
return {
|
|
3
|
+
fetchSnapshotSources: (resourceId, requestConfig) => client.get(`/store/resources/${resourceId}/snapshot-sources`, requestConfig),
|
|
4
|
+
previewResourceSnapshot: (resourceId, payloadConfig, requestConfig) => client.post(`/store/resources/${resourceId}/snapshot-preview`, { payload_config: payloadConfig }, requestConfig),
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Narrow a version's `payload_schema` to a snapshot schema.
|
|
12
|
+
*
|
|
13
|
+
* `ResourceVersion.payload_schema` is typed for snapshots because they are the only
|
|
14
|
+
* payload type that records one today, but AAD-899 may store a different shape — so
|
|
15
|
+
* a component rendering the field list should narrow rather than assume. Use this
|
|
16
|
+
* instead of a cast: `as` would happily assert a shape that is not there, and the
|
|
17
|
+
* crash lands in whichever component reads `fields` first.
|
|
18
|
+
*/
|
|
19
|
+
export function isSnapshotPayloadSchema(value) {
|
|
20
|
+
if (!isRecord(value))
|
|
21
|
+
return false;
|
|
22
|
+
// Every field the predicate asserts is verified. A guard that narrows to
|
|
23
|
+
// something it never checked is how `schema.fields.map` becomes a runtime error.
|
|
24
|
+
return typeof value.schema_version === 'number'
|
|
25
|
+
&& typeof value.row_count === 'number'
|
|
26
|
+
&& typeof value.byte_size === 'number'
|
|
27
|
+
&& Array.isArray(value.fields)
|
|
28
|
+
&& value.fields.every(field => isRecord(field)
|
|
29
|
+
&& typeof field.key === 'string'
|
|
30
|
+
&& typeof field.type === 'string'
|
|
31
|
+
&& typeof field.nullable === 'boolean'
|
|
32
|
+
&& typeof field.order === 'number'
|
|
33
|
+
&& typeof field.source_column_id === 'string');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Narrow a version's source, or a schema's, to the FILE variant (AAD-948).
|
|
37
|
+
*
|
|
38
|
+
* A runtime guard rather than a cast, because the discriminator is optional on the
|
|
39
|
+
* table half — `source.type` is absent for every version written before AAD-948 and
|
|
40
|
+
* for every table-sourced version since. `value.type === 'file'` is the only safe
|
|
41
|
+
* test, and putting it here means no call site has to remember that.
|
|
42
|
+
*/
|
|
43
|
+
export function isFileSnapshotSource(value) {
|
|
44
|
+
if (typeof value !== 'object' || value === null)
|
|
45
|
+
return false;
|
|
46
|
+
const source = value;
|
|
47
|
+
// Every asserted field is CHECKED. A guard that narrows `upload_id` to `string`
|
|
48
|
+
// on the strength of the discriminator alone hands the caller a typed value that
|
|
49
|
+
// can be undefined at runtime — the exact failure a guard exists to prevent.
|
|
50
|
+
// `verified` is deliberately not asserted here: it is not validated, and the
|
|
51
|
+
// typed union already carries it for anyone who needs it.
|
|
52
|
+
return source.type === 'file'
|
|
53
|
+
&& typeof source.upload_id === 'string'
|
|
54
|
+
&& (typeof source.sha256 === 'string' || source.sha256 === null);
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SnapshotUpload, UploadSnapshotFileData } from '../types/snapshotUploads';
|
|
2
|
+
import type { AntHttpClient } from "../../../AntHttpClient";
|
|
3
|
+
import type { DataWrapper } from "../../../types";
|
|
4
|
+
/**
|
|
5
|
+
* Staging dataset files for a snapshot version (AAD-948).
|
|
6
|
+
*
|
|
7
|
+
* Its own factory rather than more methods on `resources.ts`, which is at 228 of the
|
|
8
|
+
* 250-line limit. The public surface is unchanged — both are composed into
|
|
9
|
+
* `SellableResourceFactory` and reached as `c.apps.*`.
|
|
10
|
+
*/
|
|
11
|
+
export interface ResourceUploadFactory {
|
|
12
|
+
/**
|
|
13
|
+
* Stage a dataset file and get back what the server made of it.
|
|
14
|
+
*
|
|
15
|
+
* Synchronous: the response carries the row count, the column count and a PROPOSED
|
|
16
|
+
* type per column, which is what the publisher confirms or overrides before a
|
|
17
|
+
* version exists.
|
|
18
|
+
*
|
|
19
|
+
* **Nothing is created if the file cannot be read.** A truncated JSON document, a
|
|
20
|
+
* CSV row that disagrees with its header, binary content or non-UTF-8 text is a
|
|
21
|
+
* **422 on `errors.file`** and leaves no upload behind. Render that as "pick another
|
|
22
|
+
* file", never as a failed version — a failed version is a different event with a
|
|
23
|
+
* retry attached.
|
|
24
|
+
*/
|
|
25
|
+
uploadSnapshotFile: (resourceId: string, data: UploadSnapshotFileData, requestConfig?: Record<string, any>) => Promise<DataWrapper<SnapshotUpload>>;
|
|
26
|
+
/**
|
|
27
|
+
* Discard an upload the publisher decided against.
|
|
28
|
+
*
|
|
29
|
+
* **409 once a version has claimed it.** At that point the bytes are that version's
|
|
30
|
+
* source, and removing them would turn its retry into a re-upload for no reason the
|
|
31
|
+
* publisher asked for. Deleting the version is the way to remove those, and it takes
|
|
32
|
+
* the upload with it.
|
|
33
|
+
*/
|
|
34
|
+
deleteSnapshotUpload: (resourceId: string, uploadId: string, requestConfig?: Record<string, any>) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare function newResourceUploadFactory(client: AntHttpClient): ResourceUploadFactory;
|
|
37
|
+
//# sourceMappingURL=resourceUploads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceUploads.d.ts","sourceRoot":"","sources":["../../../../src/services/AppService/factory/resourceUploads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,+BAAuB;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAe;AAG1C;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;OAYG;IACH,kBAAkB,EAAE,CAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,sBAAsB,EAC5B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAChC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAA;IAEzC;;;;;;;OAOG;IACH,oBAAoB,EAAE,CACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAChC,OAAO,CAAC,IAAI,CAAC,CAAA;CACnB;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,GAAG,qBAAqB,CAUrF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { maybeFormData } from './formData';
|
|
2
|
+
export function newResourceUploadFactory(client) {
|
|
3
|
+
const base = (resourceId) => `/store/resources/${resourceId}/snapshot-uploads`;
|
|
4
|
+
return {
|
|
5
|
+
uploadSnapshotFile: (resourceId, data, requestConfig) => client.post(base(resourceId), maybeFormData(data), requestConfig),
|
|
6
|
+
deleteSnapshotUpload: (resourceId, uploadId, requestConfig) => client.delete(`${base(resourceId)}/${uploadId}`, requestConfig),
|
|
7
|
+
};
|
|
8
|
+
}
|