@riducms/sdk 0.1.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +862 -0
- package/dist/error.d.ts +10 -0
- package/dist/error.js +56 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/live-preview.d.ts +35 -0
- package/dist/live-preview.js +61 -0
- package/dist/types.d.ts +362 -0
- package/dist/types.js +1 -0
- package/package.json +42 -0
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ErrorCode, type ErrorPayload, type ValidationIssue } from "@riducms/protocol";
|
|
2
|
+
export declare class RiduError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly requestId: string | undefined;
|
|
6
|
+
readonly issues: readonly ValidationIssue[];
|
|
7
|
+
readonly details: unknown;
|
|
8
|
+
constructor(payload: ErrorPayload);
|
|
9
|
+
static fromResponse(response: Response): Promise<RiduError>;
|
|
10
|
+
}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { errorPayload, isErrorEnvelope, } from "@riducms/protocol";
|
|
2
|
+
export class RiduError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
status;
|
|
5
|
+
requestId;
|
|
6
|
+
issues;
|
|
7
|
+
details;
|
|
8
|
+
constructor(payload) {
|
|
9
|
+
super(payload.message);
|
|
10
|
+
this.name = "RiduError";
|
|
11
|
+
this.code = payload.code;
|
|
12
|
+
this.status = payload.status;
|
|
13
|
+
this.requestId = payload.requestId;
|
|
14
|
+
this.issues = [...payload.issues];
|
|
15
|
+
this.details = payload.details;
|
|
16
|
+
}
|
|
17
|
+
static async fromResponse(response) {
|
|
18
|
+
const body = await readJSON(response);
|
|
19
|
+
if (isErrorEnvelope(body)) {
|
|
20
|
+
return new RiduError(errorPayload(body));
|
|
21
|
+
}
|
|
22
|
+
return new RiduError({
|
|
23
|
+
code: fallbackCode(response.status),
|
|
24
|
+
status: response.status,
|
|
25
|
+
message: response.statusText
|
|
26
|
+
? `Request failed: ${response.status} ${response.statusText}`
|
|
27
|
+
: `Request failed with status ${response.status}`,
|
|
28
|
+
issues: [],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function readJSON(response) {
|
|
33
|
+
try {
|
|
34
|
+
return await response.json();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function fallbackCode(status) {
|
|
41
|
+
switch (status) {
|
|
42
|
+
case 400:
|
|
43
|
+
return "bad_request";
|
|
44
|
+
case 401:
|
|
45
|
+
case 403:
|
|
46
|
+
return "access_denied";
|
|
47
|
+
case 404:
|
|
48
|
+
return "not_found";
|
|
49
|
+
case 409:
|
|
50
|
+
return "conflict";
|
|
51
|
+
case 422:
|
|
52
|
+
return "validation";
|
|
53
|
+
default:
|
|
54
|
+
return "internal";
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createClient } from "./client.js";
|
|
2
|
+
export { RiduError } from "./error.js";
|
|
3
|
+
export { connectLivePreview, RIDU_LIVE_PREVIEW_CHANNEL_PARAM, RIDU_LIVE_PREVIEW_MESSAGE, RIDU_PREVIEW_TOKEN_PARAM, type LivePreviewConnection, type LivePreviewTarget, type RiduLivePreviewReadyMessage, type RiduLivePreviewUpdateMessage, } from "./live-preview.js";
|
|
4
|
+
export type { ClientOptions, AuthCollectionSlug, AuthUser, CollectionContract, CollectionSlug, CollectionSelectionOptions, GlobalContract, GlobalContractFor, GlobalSlug, GlobalOutputFor, GlobalAllLocalesOutputFor, GlobalUpdateFor, GlobalSelectFor, GlobalPopulateFor, DraftGlobalSlug, VersionGlobalSlug, CreateFor, CreateOptions, FindOptions, ListOptions, LocaleOptions, LoginCredentials, JoinMutationInput, Middleware, MiddlewareNext, OutputFor, AllLocalesOutputFor, PopulateFor, RequestOptions, RevisionOptions, MutationOptions, MutationLocaleOptions, RestoreOptions, CopyLocaleInput, DefaultRiduConfig, GeneratedRiduConfigRegistry, UploadCollectionSlug, UploadOptions, UploadImageInput, Version, ScheduledPublish, VersionCollectionSlug, DraftCollectionSlug, SelectFor, UpdateFor, WhereFor, RiduClient, RiduConfigShape, } from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const RIDU_LIVE_PREVIEW_MESSAGE: "ridu-live-preview";
|
|
2
|
+
export declare const RIDU_LIVE_PREVIEW_CHANNEL_PARAM: "__ridu_preview";
|
|
3
|
+
export declare const RIDU_PREVIEW_TOKEN_PARAM: "__ridu_preview_token";
|
|
4
|
+
export interface RiduLivePreviewReadyMessage {
|
|
5
|
+
type: typeof RIDU_LIVE_PREVIEW_MESSAGE;
|
|
6
|
+
ready: true;
|
|
7
|
+
channel: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RiduLivePreviewUpdateMessage<Data extends object> {
|
|
10
|
+
type: typeof RIDU_LIVE_PREVIEW_MESSAGE;
|
|
11
|
+
channel: string;
|
|
12
|
+
sequence: number;
|
|
13
|
+
resource: "collection" | "global";
|
|
14
|
+
slug: string;
|
|
15
|
+
collection: string;
|
|
16
|
+
id: string;
|
|
17
|
+
data: Data;
|
|
18
|
+
}
|
|
19
|
+
export interface LivePreviewTarget {
|
|
20
|
+
resource: "collection" | "global";
|
|
21
|
+
slug: string;
|
|
22
|
+
id: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LivePreviewConnection<Data extends object> {
|
|
25
|
+
/** Re-announces readiness after an application-side route or renderer reset. */
|
|
26
|
+
ready: () => void;
|
|
27
|
+
disconnect: () => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function connectLivePreview<Data extends object>({ adminOrigin, target: expectedTarget, onUpdate, window: injectedWindow, }: {
|
|
30
|
+
adminOrigin: string;
|
|
31
|
+
target: LivePreviewTarget;
|
|
32
|
+
onUpdate: (message: RiduLivePreviewUpdateMessage<Data>) => void;
|
|
33
|
+
/** Browser window override used by embedded renderers and tests. */
|
|
34
|
+
window?: object;
|
|
35
|
+
}): LivePreviewConnection<Data>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const RIDU_LIVE_PREVIEW_MESSAGE = "ridu-live-preview";
|
|
2
|
+
export const RIDU_LIVE_PREVIEW_CHANNEL_PARAM = "__ridu_preview";
|
|
3
|
+
export const RIDU_PREVIEW_TOKEN_PARAM = "__ridu_preview_token";
|
|
4
|
+
export function connectLivePreview({ adminOrigin, target: expectedTarget, onUpdate, window: injectedWindow = window, }) {
|
|
5
|
+
// Keep the browser-only Window type inside the implementation so importing the SDK's
|
|
6
|
+
// declarations from Node does not require TypeScript's DOM library.
|
|
7
|
+
const previewWindow = injectedWindow;
|
|
8
|
+
const expectedOrigin = new URL(adminOrigin).origin;
|
|
9
|
+
const channel = new URL(previewWindow.location.href).searchParams.get(RIDU_LIVE_PREVIEW_CHANNEL_PARAM);
|
|
10
|
+
if (channel === null || channel === "") {
|
|
11
|
+
throw new Error(`Live preview URL is missing ${RIDU_LIVE_PREVIEW_CHANNEL_PARAM}`);
|
|
12
|
+
}
|
|
13
|
+
const target = previewWindow.opener ?? previewWindow.parent;
|
|
14
|
+
if (target === previewWindow)
|
|
15
|
+
throw new Error("Live preview requires a parent iframe or opener");
|
|
16
|
+
const ready = () => {
|
|
17
|
+
target.postMessage({
|
|
18
|
+
type: RIDU_LIVE_PREVIEW_MESSAGE,
|
|
19
|
+
ready: true,
|
|
20
|
+
channel,
|
|
21
|
+
}, expectedOrigin);
|
|
22
|
+
};
|
|
23
|
+
const handleMessage = (event) => {
|
|
24
|
+
if (event.origin !== expectedOrigin || event.source !== target)
|
|
25
|
+
return;
|
|
26
|
+
if (!isLivePreviewUpdate(event.data, channel, expectedTarget))
|
|
27
|
+
return;
|
|
28
|
+
onUpdate(event.data);
|
|
29
|
+
};
|
|
30
|
+
previewWindow.addEventListener("message", handleMessage);
|
|
31
|
+
previewWindow.addEventListener("pageshow", ready);
|
|
32
|
+
previewWindow.addEventListener("focus", ready);
|
|
33
|
+
previewWindow.addEventListener("online", ready);
|
|
34
|
+
ready();
|
|
35
|
+
return {
|
|
36
|
+
ready,
|
|
37
|
+
disconnect: () => {
|
|
38
|
+
previewWindow.removeEventListener("message", handleMessage);
|
|
39
|
+
previewWindow.removeEventListener("pageshow", ready);
|
|
40
|
+
previewWindow.removeEventListener("focus", ready);
|
|
41
|
+
previewWindow.removeEventListener("online", ready);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function isLivePreviewUpdate(value, channel, target) {
|
|
46
|
+
if (value === null || typeof value !== "object")
|
|
47
|
+
return false;
|
|
48
|
+
const candidate = value;
|
|
49
|
+
return (candidate.type === RIDU_LIVE_PREVIEW_MESSAGE &&
|
|
50
|
+
candidate.channel === channel &&
|
|
51
|
+
typeof candidate.sequence === "number" &&
|
|
52
|
+
Number.isSafeInteger(candidate.sequence) &&
|
|
53
|
+
candidate.sequence >= 0 &&
|
|
54
|
+
candidate.resource === target.resource &&
|
|
55
|
+
candidate.slug === target.slug &&
|
|
56
|
+
candidate.id === target.id &&
|
|
57
|
+
typeof candidate.collection === "string" &&
|
|
58
|
+
candidate.data !== null &&
|
|
59
|
+
typeof candidate.data === "object" &&
|
|
60
|
+
!Array.isArray(candidate.data));
|
|
61
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import type { AuthSession, AuthSessionInfo, AuthActionEnvelope, AuthBootstrapEnvelope, APIKey, APIKeyInfo, AccessCapabilitiesEnvelope, CollectionSelectionEnvelope, DeleteEnvelope, CountEnvelope, LogoutEnvelope, PageEnvelope, SchemaManifest, ScheduledPublish, DocumentLockEnvelope, JoinMutationEnvelope, JoinMutationInput, PreviewToken } from "@riducms/protocol";
|
|
2
|
+
export type { JoinMutationInput, PreviewToken, ScheduledPublish } from "@riducms/protocol";
|
|
3
|
+
export interface CollectionContract {
|
|
4
|
+
auth: boolean;
|
|
5
|
+
upload: boolean;
|
|
6
|
+
versions: boolean;
|
|
7
|
+
drafts?: boolean;
|
|
8
|
+
trash: boolean;
|
|
9
|
+
output: unknown;
|
|
10
|
+
allOutput?: unknown;
|
|
11
|
+
create: unknown;
|
|
12
|
+
update: unknown;
|
|
13
|
+
where: unknown;
|
|
14
|
+
select: unknown;
|
|
15
|
+
populate: unknown;
|
|
16
|
+
populateOutput?: unknown;
|
|
17
|
+
allPopulateOutput?: unknown;
|
|
18
|
+
validationPath?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface GlobalContract {
|
|
21
|
+
versions: boolean;
|
|
22
|
+
drafts?: boolean;
|
|
23
|
+
output: unknown;
|
|
24
|
+
allOutput?: unknown;
|
|
25
|
+
update: unknown;
|
|
26
|
+
select: unknown;
|
|
27
|
+
populate: unknown;
|
|
28
|
+
populateOutput?: unknown;
|
|
29
|
+
allPopulateOutput?: unknown;
|
|
30
|
+
validationPath?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RiduConfigShape {
|
|
33
|
+
locale?: string;
|
|
34
|
+
collections: object;
|
|
35
|
+
globals?: object;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Application generators add one manifest-digest-keyed entry through module augmentation. Keeping a
|
|
39
|
+
* registry rather than extending one config directly lets explicit clients coexist in tooling and
|
|
40
|
+
* multi-application TypeScript programs without declaration-merging conflicts.
|
|
41
|
+
*/
|
|
42
|
+
export interface GeneratedRiduConfigRegistry {
|
|
43
|
+
}
|
|
44
|
+
type GeneratedRiduConfigKey = keyof GeneratedRiduConfigRegistry;
|
|
45
|
+
type IsUnion<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
|
|
46
|
+
type RegisteredRiduConfig = GeneratedRiduConfigRegistry[GeneratedRiduConfigKey];
|
|
47
|
+
/**
|
|
48
|
+
* The one generated config visible to the current TypeScript program. With none or more than one,
|
|
49
|
+
* callers use an explicit config (normally through a generated client package).
|
|
50
|
+
*/
|
|
51
|
+
export type DefaultRiduConfig = [GeneratedRiduConfigKey] extends [never] ? RiduConfigShape : true extends IsUnion<GeneratedRiduConfigKey> ? RiduConfigShape : RegisteredRiduConfig extends RiduConfigShape ? RegisteredRiduConfig : RiduConfigShape;
|
|
52
|
+
export type CollectionSlug<Config extends RiduConfigShape> = keyof Config["collections"] & string;
|
|
53
|
+
export type GlobalSlug<Config extends RiduConfigShape> = keyof NonNullable<Config["globals"]> & string;
|
|
54
|
+
export type GlobalContractFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = NonNullable<Config["globals"]>[Slug] extends GlobalContract ? NonNullable<Config["globals"]>[Slug] : never;
|
|
55
|
+
export type GlobalOutputFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug>["output"];
|
|
56
|
+
export type GlobalAllLocalesOutputFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug> extends {
|
|
57
|
+
allOutput: infer Output;
|
|
58
|
+
} ? Output : GlobalOutputFor<Config, Slug>;
|
|
59
|
+
export type GlobalUpdateFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug>["update"];
|
|
60
|
+
export type GlobalSelectFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug>["select"];
|
|
61
|
+
export type GlobalPopulateFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug>["populate"];
|
|
62
|
+
export type GlobalPopulateOutputFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug> extends {
|
|
63
|
+
populateOutput: infer Output;
|
|
64
|
+
} ? Output : Record<never, never>;
|
|
65
|
+
export type GlobalAllLocalesPopulateOutputFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug> extends {
|
|
66
|
+
allPopulateOutput: infer Output;
|
|
67
|
+
} ? Output : GlobalPopulateOutputFor<Config, Slug>;
|
|
68
|
+
export type GlobalValidationPathFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug> extends {
|
|
69
|
+
validationPath: infer Path extends string;
|
|
70
|
+
} ? Path : string;
|
|
71
|
+
export type VersionGlobalSlug<Config extends RiduConfigShape> = {
|
|
72
|
+
[Slug in GlobalSlug<Config>]: GlobalContractFor<Config, Slug>["versions"] extends true ? Slug : never;
|
|
73
|
+
}[GlobalSlug<Config>];
|
|
74
|
+
export type DraftGlobalSlug<Config extends RiduConfigShape> = {
|
|
75
|
+
[Slug in GlobalSlug<Config>]: GlobalContractFor<Config, Slug> extends {
|
|
76
|
+
drafts: true;
|
|
77
|
+
} ? Slug : GlobalContractFor<Config, Slug> extends {
|
|
78
|
+
drafts: false;
|
|
79
|
+
} ? never : GlobalContractFor<Config, Slug>["versions"] extends true ? Slug : never;
|
|
80
|
+
}[GlobalSlug<Config>];
|
|
81
|
+
export type ContractFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = Config["collections"][Slug] extends CollectionContract ? Config["collections"][Slug] : never;
|
|
82
|
+
export type OutputFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["output"];
|
|
83
|
+
export type AllLocalesOutputFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug> extends {
|
|
84
|
+
allOutput: infer Output;
|
|
85
|
+
} ? Output : OutputFor<Config, Slug>;
|
|
86
|
+
export type CreateFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["create"];
|
|
87
|
+
export type UpdateFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["update"];
|
|
88
|
+
export type WhereFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["where"];
|
|
89
|
+
export type SelectFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["select"];
|
|
90
|
+
export type PopulateFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["populate"];
|
|
91
|
+
export type PopulateOutputFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug> extends {
|
|
92
|
+
populateOutput: infer Output;
|
|
93
|
+
} ? Output : Record<never, never>;
|
|
94
|
+
export type AllLocalesPopulateOutputFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug> extends {
|
|
95
|
+
allPopulateOutput: infer Output;
|
|
96
|
+
} ? Output : PopulateOutputFor<Config, Slug>;
|
|
97
|
+
export type ValidationPathFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug> extends {
|
|
98
|
+
validationPath: infer Path extends string;
|
|
99
|
+
} ? Path : string;
|
|
100
|
+
export type LocaleFor<Config extends RiduConfigShape> = Config extends {
|
|
101
|
+
locale: infer Locale;
|
|
102
|
+
} ? Locale extends string ? Locale : never : string;
|
|
103
|
+
export type AuthUser<Config extends RiduConfigShape> = OutputFor<Config, AuthCollectionSlug<Config>>;
|
|
104
|
+
export type AuthCollectionSlug<Config extends RiduConfigShape> = {
|
|
105
|
+
[Slug in CollectionSlug<Config>]: ContractFor<Config, Slug>["auth"] extends true ? Slug : never;
|
|
106
|
+
}[CollectionSlug<Config>];
|
|
107
|
+
export type UploadCollectionSlug<Config extends RiduConfigShape> = {
|
|
108
|
+
[Slug in CollectionSlug<Config>]: ContractFor<Config, Slug>["upload"] extends true ? Slug : never;
|
|
109
|
+
}[CollectionSlug<Config>];
|
|
110
|
+
export type VersionCollectionSlug<Config extends RiduConfigShape> = {
|
|
111
|
+
[Slug in CollectionSlug<Config>]: ContractFor<Config, Slug>["versions"] extends true ? Slug : never;
|
|
112
|
+
}[CollectionSlug<Config>];
|
|
113
|
+
export type DraftCollectionSlug<Config extends RiduConfigShape> = {
|
|
114
|
+
[Slug in CollectionSlug<Config>]: ContractFor<Config, Slug> extends {
|
|
115
|
+
drafts: true;
|
|
116
|
+
} ? Slug : ContractFor<Config, Slug> extends {
|
|
117
|
+
drafts: false;
|
|
118
|
+
} ? never : ContractFor<Config, Slug>["versions"] extends true ? Slug : never;
|
|
119
|
+
}[CollectionSlug<Config>];
|
|
120
|
+
export type CollectionVersionsFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug>["versions"];
|
|
121
|
+
export type CollectionDraftsFor<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>> = ContractFor<Config, Slug> extends {
|
|
122
|
+
drafts: infer Drafts extends boolean;
|
|
123
|
+
} ? Drafts : CollectionVersionsFor<Config, Slug>;
|
|
124
|
+
export type GlobalDraftsFor<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>> = GlobalContractFor<Config, Slug> extends {
|
|
125
|
+
drafts: infer Drafts extends boolean;
|
|
126
|
+
} ? Drafts : GlobalContractFor<Config, Slug>["versions"];
|
|
127
|
+
export type TrashCollectionSlug<Config extends RiduConfigShape> = {
|
|
128
|
+
[Slug in CollectionSlug<Config>]: ContractFor<Config, Slug>["trash"] extends true ? Slug : never;
|
|
129
|
+
}[CollectionSlug<Config>];
|
|
130
|
+
export interface LoginCredentials {
|
|
131
|
+
email: string;
|
|
132
|
+
password: string;
|
|
133
|
+
}
|
|
134
|
+
export interface CreateAPIKeyInput {
|
|
135
|
+
name: string;
|
|
136
|
+
expiresAt?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface RequestOptions {
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
headers?: ConstructorParameters<typeof Headers>[0];
|
|
141
|
+
keepalive?: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface LocaleOptions<Locale extends string = string> extends RequestOptions {
|
|
144
|
+
/** Content locale. Use "all" to receive locale-keyed localized fields. */
|
|
145
|
+
locale?: [Locale] extends [never] ? never : Locale | "all";
|
|
146
|
+
/** Explicit fallback chain, or false to require an exact locale value. */
|
|
147
|
+
fallbackLocale?: [Locale] extends [never] ? never : Locale | readonly Locale[] | false;
|
|
148
|
+
}
|
|
149
|
+
interface SingleLocaleMutationOptions<Locale extends string = string> extends Omit<LocaleOptions<Locale>, "locale"> {
|
|
150
|
+
/** Mutations target one locale; `"all"` is read-only. */
|
|
151
|
+
locale?: Locale;
|
|
152
|
+
}
|
|
153
|
+
/** Locale-aware mutation options for methods that do not consume a revision. */
|
|
154
|
+
export interface MutationLocaleOptions<Locale extends string = string> extends SingleLocaleMutationOptions<Locale> {
|
|
155
|
+
/** This method has no optimistic-concurrency transport contract. */
|
|
156
|
+
revision?: never;
|
|
157
|
+
}
|
|
158
|
+
/** Locale-aware mutation options for methods that send an optimistic revision. */
|
|
159
|
+
export interface MutationOptions<Locale extends string = string> extends SingleLocaleMutationOptions<Locale> {
|
|
160
|
+
revision?: number;
|
|
161
|
+
}
|
|
162
|
+
/** Optimistic-concurrency options for mutations that have no locale semantics. */
|
|
163
|
+
export interface RevisionOptions extends RequestOptions {
|
|
164
|
+
revision?: number;
|
|
165
|
+
/** This mutation does not select or return a content locale. */
|
|
166
|
+
locale?: never;
|
|
167
|
+
/** This mutation does not resolve localized fallback values. */
|
|
168
|
+
fallbackLocale?: never;
|
|
169
|
+
}
|
|
170
|
+
type DraftCreateOption<Versions extends boolean, Drafts extends boolean> = [Versions] extends [
|
|
171
|
+
false
|
|
172
|
+
] ? {
|
|
173
|
+
draft?: never;
|
|
174
|
+
} : [Drafts] extends [false] ? {
|
|
175
|
+
draft?: false;
|
|
176
|
+
} : {
|
|
177
|
+
draft?: boolean;
|
|
178
|
+
};
|
|
179
|
+
export type CreateOptions<Locale extends string = string, Versions extends boolean = boolean, Drafts extends boolean = boolean> = MutationLocaleOptions<Locale> & DraftCreateOption<Versions, Drafts>;
|
|
180
|
+
export type RestoreOptions<Locale extends string = string, Drafts extends boolean = boolean> = MutationOptions<Locale> & ([Drafts] extends [false] ? {
|
|
181
|
+
draft?: false;
|
|
182
|
+
} : {
|
|
183
|
+
draft?: boolean;
|
|
184
|
+
});
|
|
185
|
+
export interface CopyLocaleInput<Locale extends string = string> {
|
|
186
|
+
from: Locale;
|
|
187
|
+
to: Locale;
|
|
188
|
+
}
|
|
189
|
+
export interface UploadOptions<Data, Locale extends string = string> extends MutationLocaleOptions<Locale> {
|
|
190
|
+
data?: Partial<Data>;
|
|
191
|
+
}
|
|
192
|
+
export interface UploadImageInput {
|
|
193
|
+
focalX: number;
|
|
194
|
+
focalY: number;
|
|
195
|
+
cropX?: number;
|
|
196
|
+
cropY?: number;
|
|
197
|
+
cropWidth?: number;
|
|
198
|
+
cropHeight?: number;
|
|
199
|
+
}
|
|
200
|
+
export interface CollectionAccessOptions<Data, Locale extends string = string> extends LocaleOptions<Locale> {
|
|
201
|
+
id?: string;
|
|
202
|
+
data?: Partial<Data>;
|
|
203
|
+
trash?: boolean;
|
|
204
|
+
}
|
|
205
|
+
export interface CollectionSelectionOptions<Where, Locale extends string = string> extends LocaleOptions<Locale> {
|
|
206
|
+
where?: Where;
|
|
207
|
+
trash?: boolean;
|
|
208
|
+
}
|
|
209
|
+
export interface GlobalAccessOptions<Data, Locale extends string = string> extends LocaleOptions<Locale> {
|
|
210
|
+
data?: Partial<Data>;
|
|
211
|
+
}
|
|
212
|
+
type DocumentStatus<Document> = Document extends {
|
|
213
|
+
_status: infer Status;
|
|
214
|
+
} ? Extract<Status, "draft" | "published"> : "draft" | "published";
|
|
215
|
+
export interface Version<Document> {
|
|
216
|
+
ID: string;
|
|
217
|
+
DocumentID: string;
|
|
218
|
+
Revision: number;
|
|
219
|
+
Status: DocumentStatus<Document>;
|
|
220
|
+
Snapshot: Document;
|
|
221
|
+
CreatedAt: string;
|
|
222
|
+
}
|
|
223
|
+
export interface ListOptions<Where, Select, Populate, Locale extends string = string> extends LocaleOptions<Locale> {
|
|
224
|
+
page?: number;
|
|
225
|
+
limit?: number;
|
|
226
|
+
depth?: number;
|
|
227
|
+
where?: Where;
|
|
228
|
+
select?: Select;
|
|
229
|
+
populate?: Populate;
|
|
230
|
+
sort?: readonly string[];
|
|
231
|
+
trash?: boolean;
|
|
232
|
+
}
|
|
233
|
+
export interface FindOptions<Select, Populate, Locale extends string = string> extends LocaleOptions<Locale> {
|
|
234
|
+
depth?: number;
|
|
235
|
+
select?: Select;
|
|
236
|
+
populate?: Populate;
|
|
237
|
+
}
|
|
238
|
+
type DocumentMetadataKey = "id" | "createdAt" | "updatedAt" | "deletedAt" | "_status" | "_revision" | "_localization";
|
|
239
|
+
type SelectedKey<Selection> = Selection extends object ? {
|
|
240
|
+
[Key in keyof Selection]-?: Selection[Key] extends true ? Key : never;
|
|
241
|
+
}[keyof Selection] : never;
|
|
242
|
+
type HasWidenedSelection<Selection> = Selection extends object ? boolean extends Exclude<Selection[keyof Selection], undefined> ? true : false : false;
|
|
243
|
+
type HasOnlyBooleanSelectionValues<Selection> = Selection extends object ? Exclude<Selection[keyof Selection], undefined> extends boolean ? true : false : false;
|
|
244
|
+
/** Applies the REST top-level boolean projection while retaining always-returned metadata. */
|
|
245
|
+
export type ApplySelect<Document, Selection> = [Selection] extends [undefined] ? Document : HasWidenedSelection<Selection> extends true ? Document : Document extends object ? Pick<Document, Extract<DocumentMetadataKey | SelectedKey<Selection>, keyof Document>> : Document;
|
|
246
|
+
type PopulationSelection<Option> = Option extends boolean ? undefined : HasOnlyBooleanSelectionValues<Option> extends true ? Option : "select" extends keyof Option ? Option extends {
|
|
247
|
+
select?: infer Selection;
|
|
248
|
+
} ? Selection : undefined : undefined;
|
|
249
|
+
type NarrowPopulatedValue<Value, Option> = Value extends readonly (infer Item)[] ? Array<NarrowPopulatedValue<Item, Option>> : Value extends {
|
|
250
|
+
relationTo: infer Relation;
|
|
251
|
+
id: infer IDValue;
|
|
252
|
+
} ? Omit<Value, "relationTo" | "id"> & {
|
|
253
|
+
relationTo: Relation;
|
|
254
|
+
id: NarrowPopulatedValue<IDValue, Option>;
|
|
255
|
+
} : Value extends {
|
|
256
|
+
id: unknown;
|
|
257
|
+
} ? ApplySelect<Value, PopulationSelection<Option>> : Value extends object ? {
|
|
258
|
+
[Key in keyof Value]: NarrowPopulatedValue<Value[Key], Option>;
|
|
259
|
+
} : Value;
|
|
260
|
+
type DataPath<Value, Prefix extends string, Key extends string> = Value extends {
|
|
261
|
+
blockType: infer Block extends string;
|
|
262
|
+
} ? Key extends "blockType" ? `${Prefix}.blockType` : `${Prefix}.${Block}.${Key}` : Prefix extends "" ? Key : `${Prefix}.${Key}`;
|
|
263
|
+
type IsDefinitePopulationOption<Option> = undefined extends Option ? false : [Option] extends [object] ? true : false extends Option ? false : true;
|
|
264
|
+
type HasDefinitePopulation<Population, Path extends PropertyKey> = Path extends keyof Population ? IsDefinitePopulationOption<Population[Path]> : false;
|
|
265
|
+
type IsLocaleMap<Value, Locale extends string> = [Locale] extends [never] ? false : Value extends object ? typeof Symbol.toStringTag extends keyof Value ? true : false : false;
|
|
266
|
+
type ApplyPopulationTree<Value, Mapping, Population, Locale extends string, Prefix extends string = ""> = Value extends null | undefined ? Value : Value extends readonly (infer Item)[] ? Array<ApplyPopulationTree<Item, Mapping, Population, Locale, Prefix>> : Value extends object ? IsLocaleMap<Value, Locale> extends true ? {
|
|
267
|
+
[Key in keyof Value]: ApplyPopulationTree<Value[Key], Mapping, Population, Locale, Prefix>;
|
|
268
|
+
} : {
|
|
269
|
+
[Key in keyof Value]: Key extends string ? DataPath<Value, Prefix, Key> extends infer Path extends string ? Path extends keyof Mapping ? HasDefinitePopulation<Population, Path> extends true ? NarrowPopulatedValue<Mapping[Path], Population[Path & keyof Population]> : ApplyPopulationTree<Value[Key], Mapping, Population, Locale, Path> : ApplyPopulationTree<Value[Key], Mapping, Population, Locale, Path> : Value[Key] : Value[Key];
|
|
270
|
+
} : Value;
|
|
271
|
+
/** Applies every explicit canonical populate path, including array and block traversal. */
|
|
272
|
+
export type ApplyPopulate<Document, Mapping, Population, Locale extends string = never> = Population extends object ? [keyof Mapping & string] extends [never] ? Document : ApplyPopulationTree<Document, Mapping, Population, Locale> : Document;
|
|
273
|
+
type OptionProperty<Options, Key extends PropertyKey> = Options extends object ? Key extends keyof Options ? Options[Key] : undefined : undefined;
|
|
274
|
+
export type LocaleResult<Single, All, Options> = Options extends object ? "locale" extends keyof Options ? "all" extends OptionProperty<Options, "locale"> ? OptionProperty<Options, "locale"> extends "all" ? All : Single | All : Single : Single : Single;
|
|
275
|
+
export type CollectionQueryResult<Config extends RiduConfigShape, Slug extends CollectionSlug<Config>, Options> = LocaleResult<ApplySelect<ApplyPopulate<OutputFor<Config, Slug>, PopulateOutputFor<Config, Slug>, OptionProperty<Options, "populate">>, OptionProperty<Options, "select">>, ApplySelect<ApplyPopulate<AllLocalesOutputFor<Config, Slug>, AllLocalesPopulateOutputFor<Config, Slug>, OptionProperty<Options, "populate">, LocaleFor<Config>>, OptionProperty<Options, "select">>, Options>;
|
|
276
|
+
export type GlobalQueryResult<Config extends RiduConfigShape, Slug extends GlobalSlug<Config>, Options> = LocaleResult<ApplySelect<ApplyPopulate<GlobalOutputFor<Config, Slug>, GlobalPopulateOutputFor<Config, Slug>, OptionProperty<Options, "populate">>, OptionProperty<Options, "select">>, ApplySelect<ApplyPopulate<GlobalAllLocalesOutputFor<Config, Slug>, GlobalAllLocalesPopulateOutputFor<Config, Slug>, OptionProperty<Options, "populate">, LocaleFor<Config>>, OptionProperty<Options, "select">>, Options>;
|
|
277
|
+
export interface ClientOptions {
|
|
278
|
+
baseURL: string;
|
|
279
|
+
fetch?: (input: Parameters<typeof globalThis.fetch>[0], init?: Parameters<typeof globalThis.fetch>[1]) => ReturnType<typeof globalThis.fetch>;
|
|
280
|
+
headers?: ConstructorParameters<typeof Headers>[0] | (() => ConstructorParameters<typeof Headers>[0] | Promise<ConstructorParameters<typeof Headers>[0]>);
|
|
281
|
+
credentials?: RequestInit["credentials"];
|
|
282
|
+
middleware?: readonly Middleware[];
|
|
283
|
+
}
|
|
284
|
+
export type MiddlewareNext = (request: Request) => Promise<Response>;
|
|
285
|
+
export type Middleware = (request: Request, next: MiddlewareNext) => Promise<Response>;
|
|
286
|
+
export interface RiduClient<Config extends RiduConfigShape = DefaultRiduConfig> {
|
|
287
|
+
schema(options?: RequestOptions): Promise<SchemaManifest>;
|
|
288
|
+
request(path: string, init?: RequestInit, options?: RequestOptions): Promise<Response>;
|
|
289
|
+
requestPlugin<Result = unknown>(plugin: string, path: string, body: unknown, options?: RequestOptions): Promise<Result>;
|
|
290
|
+
login<Slug extends AuthCollectionSlug<Config>>(collection: Slug, credentials: LoginCredentials, options?: RequestOptions): Promise<AuthSession<OutputFor<Config, Slug>>>;
|
|
291
|
+
session(options?: RequestOptions): Promise<AuthSession<AuthUser<Config>>>;
|
|
292
|
+
refreshSession(options?: RequestOptions): Promise<AuthSession<AuthUser<Config>>>;
|
|
293
|
+
logout(options?: RequestOptions): Promise<LogoutEnvelope>;
|
|
294
|
+
logoutAll(options?: RequestOptions): Promise<LogoutEnvelope>;
|
|
295
|
+
sessions(options?: RequestOptions): Promise<AuthSessionInfo[]>;
|
|
296
|
+
revokeSession(id: string, options?: RequestOptions): Promise<DeleteEnvelope>;
|
|
297
|
+
requestPasswordReset<Slug extends AuthCollectionSlug<Config>>(collection: Slug, email: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
298
|
+
resetPassword<Slug extends AuthCollectionSlug<Config>>(collection: Slug, token: string, password: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
299
|
+
authBootstrap<Slug extends AuthCollectionSlug<Config>>(collection: Slug, options?: RequestOptions): Promise<AuthBootstrapEnvelope>;
|
|
300
|
+
createAuthUser<Slug extends AuthCollectionSlug<Config>>(collection: Slug, data: CreateFor<Config, Slug>, password: string, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
301
|
+
requestVerification<Slug extends AuthCollectionSlug<Config>>(collection: Slug, email: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
302
|
+
verifyEmail<Slug extends AuthCollectionSlug<Config>>(collection: Slug, token: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
303
|
+
changePassword(currentPassword: string, password: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
304
|
+
createAPIKey(input: CreateAPIKeyInput, options?: RequestOptions): Promise<APIKey>;
|
|
305
|
+
apiKeys(options?: RequestOptions): Promise<APIKeyInfo[]>;
|
|
306
|
+
revokeAPIKey(id: string, options?: RequestOptions): Promise<DeleteEnvelope>;
|
|
307
|
+
forceUnlock<Slug extends AuthCollectionSlug<Config>>(collection: Slug, id: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
308
|
+
preference<Value = unknown>(key: string, options?: RequestOptions): Promise<Value>;
|
|
309
|
+
setPreference<Value>(key: string, value: Value, options?: RequestOptions): Promise<Value>;
|
|
310
|
+
deletePreference(key: string, options?: RequestOptions): Promise<DeleteEnvelope>;
|
|
311
|
+
resetPreferences(options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
312
|
+
collectionAccess<Slug extends CollectionSlug<Config>>(collection: Slug, options?: CollectionAccessOptions<CreateFor<Config, Slug> & UpdateFor<Config, Slug>, LocaleFor<Config>>): Promise<AccessCapabilitiesEnvelope>;
|
|
313
|
+
resolveFilteredSelection<Slug extends CollectionSlug<Config>>(collection: Slug, options?: CollectionSelectionOptions<WhereFor<Config, Slug>, LocaleFor<Config>>): Promise<CollectionSelectionEnvelope>;
|
|
314
|
+
documentLock<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, options?: RequestOptions): Promise<DocumentLockEnvelope>;
|
|
315
|
+
acquireDocumentLock<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, takeover?: boolean, options?: RequestOptions): Promise<DocumentLockEnvelope>;
|
|
316
|
+
releaseDocumentLock<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, options?: RequestOptions): Promise<DeleteEnvelope>;
|
|
317
|
+
globalAccess<Slug extends GlobalSlug<Config>>(slug: Slug, options?: GlobalAccessOptions<GlobalUpdateFor<Config, Slug>, LocaleFor<Config>>): Promise<AccessCapabilitiesEnvelope>;
|
|
318
|
+
createPreviewToken<Slug extends DraftCollectionSlug<Config>>(collection: Slug, id: string, options?: RequestOptions): Promise<PreviewToken>;
|
|
319
|
+
revokePreviewToken(token: string, options?: RequestOptions): Promise<AuthActionEnvelope>;
|
|
320
|
+
preview<Slug extends DraftCollectionSlug<Config>>(collection: Slug, id: string, token: string, options?: RequestOptions): Promise<OutputFor<Config, Slug>>;
|
|
321
|
+
createGlobalPreviewToken<Slug extends DraftGlobalSlug<Config>>(slug: Slug, options?: RequestOptions): Promise<PreviewToken>;
|
|
322
|
+
previewGlobal<Slug extends DraftGlobalSlug<Config>>(slug: Slug, token: string, options?: RequestOptions): Promise<GlobalOutputFor<Config, Slug>>;
|
|
323
|
+
list<Slug extends CollectionSlug<Config>, const Options extends ListOptions<WhereFor<Config, Slug>, SelectFor<Config, Slug>, PopulateFor<Config, Slug>, LocaleFor<Config>> | undefined = undefined>(collection: Slug, options?: Options): Promise<PageEnvelope<CollectionQueryResult<Config, Slug, Options>>>;
|
|
324
|
+
count<Slug extends CollectionSlug<Config>>(collection: Slug, options?: Pick<ListOptions<WhereFor<Config, Slug>, never, never, LocaleFor<Config>>, "where" | "trash" | "locale" | "fallbackLocale" | "signal" | "headers">): Promise<CountEnvelope>;
|
|
325
|
+
find<Slug extends CollectionSlug<Config>, const Options extends FindOptions<SelectFor<Config, Slug>, PopulateFor<Config, Slug>, LocaleFor<Config>> | undefined = undefined>(collection: Slug, id: string, options?: Options): Promise<CollectionQueryResult<Config, Slug, Options>>;
|
|
326
|
+
create<Slug extends CollectionSlug<Config>>(collection: Slug, data: CreateFor<Config, Slug>, options?: CreateOptions<LocaleFor<Config>, CollectionVersionsFor<Config, Slug>, CollectionDraftsFor<Config, Slug>>): Promise<OutputFor<Config, Slug>>;
|
|
327
|
+
duplicate<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, overrides?: Partial<Omit<CreateFor<Config, Slug>, "id">>, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
328
|
+
copyLocale<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, input: CopyLocaleInput<LocaleFor<Config>>, options?: RevisionOptions): Promise<OutputFor<Config, Slug>>;
|
|
329
|
+
update<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, data: UpdateFor<Config, Slug>, options?: MutationOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
330
|
+
mutateJoin<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, field: string, input: JoinMutationInput, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<JoinMutationEnvelope<OutputFor<Config, Slug>>>;
|
|
331
|
+
delete<Slug extends CollectionSlug<Config>>(collection: Slug, id: string, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<DeleteEnvelope>;
|
|
332
|
+
bulkUpdate<Slug extends CollectionSlug<Config>>(collection: Slug, ids: readonly string[], data: UpdateFor<Config, Slug>, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
333
|
+
bulkPublish<Slug extends VersionCollectionSlug<Config>>(collection: Slug, ids: readonly string[], options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
334
|
+
bulkUnpublish<Slug extends DraftCollectionSlug<Config>>(collection: Slug, ids: readonly string[], options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
335
|
+
bulkDelete<Slug extends CollectionSlug<Config>>(collection: Slug, ids: readonly string[], options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
336
|
+
bulkRestoreDeleted<Slug extends TrashCollectionSlug<Config>>(collection: Slug, ids: readonly string[], options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
337
|
+
bulkDeletePermanent<Slug extends TrashCollectionSlug<Config>>(collection: Slug, ids: readonly string[], options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
338
|
+
emptyTrash<Slug extends TrashCollectionSlug<Config>>(collection: Slug, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>[]>;
|
|
339
|
+
restoreDeleted<Slug extends TrashCollectionSlug<Config>>(collection: Slug, id: string, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
340
|
+
deletePermanent<Slug extends TrashCollectionSlug<Config>>(collection: Slug, id: string, options?: MutationLocaleOptions<LocaleFor<Config>>): Promise<DeleteEnvelope>;
|
|
341
|
+
upload<Slug extends UploadCollectionSlug<Config>>(collection: Slug, file: Blob, options?: UploadOptions<CreateFor<Config, Slug>, LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
342
|
+
uploadFromURL<Slug extends UploadCollectionSlug<Config>>(collection: Slug, url: string, options?: UploadOptions<CreateFor<Config, Slug>, LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
343
|
+
updateUploadImage<Slug extends UploadCollectionSlug<Config>>(collection: Slug, id: string, input: UploadImageInput, options?: RevisionOptions): Promise<OutputFor<Config, Slug>>;
|
|
344
|
+
versions<Slug extends VersionCollectionSlug<Config>, const Options extends LocaleOptions<LocaleFor<Config>> | undefined = undefined>(collection: Slug, id: string, options?: Options): Promise<Version<LocaleResult<OutputFor<Config, Slug>, AllLocalesOutputFor<Config, Slug>, Options>>[]>;
|
|
345
|
+
version<Slug extends VersionCollectionSlug<Config>, const Options extends LocaleOptions<LocaleFor<Config>> | undefined = undefined>(collection: Slug, id: string, revision: number, options?: Options): Promise<Version<LocaleResult<OutputFor<Config, Slug>, AllLocalesOutputFor<Config, Slug>, Options>>>;
|
|
346
|
+
schedulePublish<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, runAt: string | Date, options?: RevisionOptions): Promise<ScheduledPublish>;
|
|
347
|
+
scheduledPublishes<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, options?: RequestOptions): Promise<ScheduledPublish[]>;
|
|
348
|
+
cancelScheduledPublish<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, jobID: string, options?: RequestOptions): Promise<DeleteEnvelope>;
|
|
349
|
+
publish<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, options?: MutationOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
350
|
+
publishChanges<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, data: UpdateFor<Config, Slug>, options?: MutationOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
351
|
+
unpublish<Slug extends DraftCollectionSlug<Config>>(collection: Slug, id: string, options?: MutationOptions<LocaleFor<Config>>): Promise<OutputFor<Config, Slug>>;
|
|
352
|
+
restore<Slug extends VersionCollectionSlug<Config>>(collection: Slug, id: string, revision: number, options?: RestoreOptions<LocaleFor<Config>, CollectionDraftsFor<Config, Slug>>): Promise<OutputFor<Config, Slug>>;
|
|
353
|
+
global<Slug extends GlobalSlug<Config>, const Options extends FindOptions<GlobalSelectFor<Config, Slug>, GlobalPopulateFor<Config, Slug>, LocaleFor<Config>> | undefined = undefined>(slug: Slug, options?: Options): Promise<GlobalQueryResult<Config, Slug, Options>>;
|
|
354
|
+
updateGlobal<Slug extends GlobalSlug<Config>>(slug: Slug, data: GlobalUpdateFor<Config, Slug>, options?: MutationOptions<LocaleFor<Config>>): Promise<GlobalOutputFor<Config, Slug>>;
|
|
355
|
+
copyGlobalLocale<Slug extends GlobalSlug<Config>>(slug: Slug, input: CopyLocaleInput<LocaleFor<Config>>, options?: RevisionOptions): Promise<GlobalOutputFor<Config, Slug>>;
|
|
356
|
+
globalVersions<Slug extends VersionGlobalSlug<Config>, const Options extends LocaleOptions<LocaleFor<Config>> | undefined = undefined>(slug: Slug, options?: Options): Promise<Version<LocaleResult<GlobalOutputFor<Config, Slug>, GlobalAllLocalesOutputFor<Config, Slug>, Options>>[]>;
|
|
357
|
+
globalVersion<Slug extends VersionGlobalSlug<Config>, const Options extends LocaleOptions<LocaleFor<Config>> | undefined = undefined>(slug: Slug, revision: number, options?: Options): Promise<Version<LocaleResult<GlobalOutputFor<Config, Slug>, GlobalAllLocalesOutputFor<Config, Slug>, Options>>>;
|
|
358
|
+
publishGlobal<Slug extends VersionGlobalSlug<Config>>(slug: Slug, options?: MutationOptions<LocaleFor<Config>>): Promise<GlobalOutputFor<Config, Slug>>;
|
|
359
|
+
publishGlobalChanges<Slug extends VersionGlobalSlug<Config>>(slug: Slug, data: GlobalUpdateFor<Config, Slug>, options?: MutationOptions<LocaleFor<Config>>): Promise<GlobalOutputFor<Config, Slug>>;
|
|
360
|
+
unpublishGlobal<Slug extends DraftGlobalSlug<Config>>(slug: Slug, options?: MutationOptions<LocaleFor<Config>>): Promise<GlobalOutputFor<Config, Slug>>;
|
|
361
|
+
restoreGlobal<Slug extends VersionGlobalSlug<Config>>(slug: Slug, revision: number, options?: RestoreOptions<LocaleFor<Config>, GlobalDraftsFor<Config, Slug>>): Promise<GlobalOutputFor<Config, Slug>>;
|
|
362
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bugs": {
|
|
3
|
+
"url": "https://github.com/riducms/ridu/issues"
|
|
4
|
+
},
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@riducms/protocol": "0.1.0"
|
|
7
|
+
},
|
|
8
|
+
"description": "Fetch-based TypeScript client runtime for generated Ridu application contracts.",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"default": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://riducms.com",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"name": "@riducms/sdk",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"provenance": true
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"directory": "packages/sdk",
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/riducms/ridu.git"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json",
|
|
35
|
+
"check": "tsc -p tsconfig.json",
|
|
36
|
+
"test": "bun run --cwd ../protocol build && bun test",
|
|
37
|
+
"test:workspace": "bun test"
|
|
38
|
+
},
|
|
39
|
+
"type": "module",
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"version": "0.1.0"
|
|
42
|
+
}
|