@webiny/sdk 0.0.0-unstable.3c5210ad37

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.
Files changed (51) hide show
  1. package/BaseError.d.ts +17 -0
  2. package/BaseError.js +10 -0
  3. package/BaseError.js.map +1 -0
  4. package/CmsSdk.d.ts +23 -0
  5. package/CmsSdk.js +36 -0
  6. package/CmsSdk.js.map +1 -0
  7. package/LICENSE +21 -0
  8. package/README.md +11 -0
  9. package/Result.d.ts +102 -0
  10. package/Result.js +143 -0
  11. package/Result.js.map +1 -0
  12. package/Webiny.d.ts +8 -0
  13. package/Webiny.js +14 -0
  14. package/Webiny.js.map +1 -0
  15. package/errors.d.ts +29 -0
  16. package/errors.js +43 -0
  17. package/errors.js.map +1 -0
  18. package/index.d.ts +13 -0
  19. package/index.js +11 -0
  20. package/index.js.map +1 -0
  21. package/methods/cms/cmsTypes.d.ts +82 -0
  22. package/methods/cms/cmsTypes.js +3 -0
  23. package/methods/cms/cmsTypes.js.map +1 -0
  24. package/methods/cms/createEntry.d.ts +67 -0
  25. package/methods/cms/createEntry.js +59 -0
  26. package/methods/cms/createEntry.js.map +1 -0
  27. package/methods/cms/deleteEntryRevision.d.ts +20 -0
  28. package/methods/cms/deleteEntryRevision.js +53 -0
  29. package/methods/cms/deleteEntryRevision.js.map +1 -0
  30. package/methods/cms/getEntry.d.ts +32 -0
  31. package/methods/cms/getEntry.js +60 -0
  32. package/methods/cms/getEntry.js.map +1 -0
  33. package/methods/cms/listEntries.d.ts +38 -0
  34. package/methods/cms/listEntries.js +90 -0
  35. package/methods/cms/listEntries.js.map +1 -0
  36. package/methods/cms/publishEntryRevision.d.ts +22 -0
  37. package/methods/cms/publishEntryRevision.js +54 -0
  38. package/methods/cms/publishEntryRevision.js.map +1 -0
  39. package/methods/cms/unpublishEntryRevision.d.ts +22 -0
  40. package/methods/cms/unpublishEntryRevision.js +54 -0
  41. package/methods/cms/unpublishEntryRevision.js.map +1 -0
  42. package/methods/cms/updateEntryRevision.d.ts +67 -0
  43. package/methods/cms/updateEntryRevision.js +62 -0
  44. package/methods/cms/updateEntryRevision.js.map +1 -0
  45. package/methods/executeGraphQL.d.ts +4 -0
  46. package/methods/executeGraphQL.js +46 -0
  47. package/methods/executeGraphQL.js.map +1 -0
  48. package/package.json +25 -0
  49. package/types.d.ts +7 -0
  50. package/types.js +3 -0
  51. package/types.js.map +1 -0
package/BaseError.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export interface ErrorOptions {
2
+ stack?: string;
3
+ }
4
+ type ErrorDataWithOptionalData<TData> = TData extends void ? {
5
+ message: string;
6
+ data?: never;
7
+ } : {
8
+ message: string;
9
+ data: TData;
10
+ };
11
+ export declare abstract class BaseError<TData = void> extends Error {
12
+ abstract readonly code: string;
13
+ readonly data: TData extends void ? undefined : TData;
14
+ readonly message: string;
15
+ protected constructor(input: ErrorDataWithOptionalData<TData>, options?: ErrorOptions);
16
+ }
17
+ export {};
package/BaseError.js ADDED
@@ -0,0 +1,10 @@
1
+ export class BaseError extends Error {
2
+ constructor(input, options) {
3
+ super(input.message);
4
+ this.message = input.message;
5
+ this.stack = options?.stack;
6
+ this.data = input.data;
7
+ }
8
+ }
9
+
10
+ //# sourceMappingURL=BaseError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BaseError","Error","constructor","input","options","message","stack","data"],"sources":["BaseError.ts"],"sourcesContent":["export interface ErrorOptions {\n stack?: string;\n}\n\ntype ErrorDataWithOptionalData<TData> = TData extends void\n ? { message: string; data?: never }\n : { message: string; data: TData };\n\nexport abstract class BaseError<TData = void> extends Error {\n public abstract readonly code: string;\n public readonly data: TData extends void ? undefined : TData;\n public override readonly message: string;\n\n protected constructor(input: ErrorDataWithOptionalData<TData>, options?: ErrorOptions) {\n super(input.message);\n this.message = input.message;\n this.stack = options?.stack;\n this.data = input.data as any;\n }\n}\n"],"mappings":"AAQA,OAAO,MAAeA,SAAS,SAAuBC,KAAK,CAAC;EAK9CC,WAAWA,CAACC,KAAuC,EAAEC,OAAsB,EAAE;IACnF,KAAK,CAACD,KAAK,CAACE,OAAO,CAAC;IACpB,IAAI,CAACA,OAAO,GAAGF,KAAK,CAACE,OAAO;IAC5B,IAAI,CAACC,KAAK,GAAGF,OAAO,EAAEE,KAAK;IAC3B,IAAI,CAACC,IAAI,GAAGJ,KAAK,CAACI,IAAW;EACjC;AACJ","ignoreList":[]}
package/CmsSdk.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { WebinyConfig } from "./types.js";
2
+ import type { CmsEntryValues, CmsEntryData } from "./methods/cms/cmsTypes.js";
3
+ import type { GetEntryParams } from "./methods/cms/getEntry.js";
4
+ import type { ListEntriesParams, ListEntriesResult } from "./methods/cms/listEntries.js";
5
+ import type { CreateEntryParams, CreateCmsEntryData } from "./methods/cms/createEntry.js";
6
+ import type { UpdateEntryRevisionParams, UpdateCmsEntryData } from "./methods/cms/updateEntryRevision.js";
7
+ import type { DeleteEntryRevisionParams } from "./methods/cms/deleteEntryRevision.js";
8
+ import type { PublishEntryRevisionParams } from "./methods/cms/publishEntryRevision.js";
9
+ import type { UnpublishEntryRevisionParams } from "./methods/cms/unpublishEntryRevision.js";
10
+ import type { HttpError, GraphQLError, NetworkError } from "./errors.js";
11
+ import type { Result } from "./Result.js";
12
+ export declare class CmsSdk {
13
+ private config;
14
+ private fetchFn;
15
+ constructor(config: WebinyConfig);
16
+ getEntry<TValues extends CmsEntryValues = CmsEntryValues>(params: GetEntryParams): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
17
+ listEntries<TValues extends CmsEntryValues = CmsEntryValues>(params: ListEntriesParams): Promise<Result<ListEntriesResult<TValues>, HttpError | GraphQLError | NetworkError>>;
18
+ createEntry<TValues extends CmsEntryValues = CmsEntryValues>(params: CreateEntryParams<TValues>): Promise<Result<CreateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
19
+ updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(params: UpdateEntryRevisionParams<TValues>): Promise<Result<UpdateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
20
+ deleteEntryRevision(params: DeleteEntryRevisionParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
21
+ publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(params: PublishEntryRevisionParams): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
22
+ unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(params: UnpublishEntryRevisionParams): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
23
+ }
package/CmsSdk.js ADDED
@@ -0,0 +1,36 @@
1
+ import { getEntry as getEntryFn } from "./methods/cms/getEntry.js";
2
+ import { listEntries as listEntriesFn } from "./methods/cms/listEntries.js";
3
+ import { createEntry as createEntryFn } from "./methods/cms/createEntry.js";
4
+ import { updateEntryRevision as updateEntryRevisionFn } from "./methods/cms/updateEntryRevision.js";
5
+ import { deleteEntryRevision as deleteEntryRevisionFn } from "./methods/cms/deleteEntryRevision.js";
6
+ import { publishEntryRevision as publishEntryRevisionFn } from "./methods/cms/publishEntryRevision.js";
7
+ import { unpublishEntryRevision as unpublishEntryRevisionFn } from "./methods/cms/unpublishEntryRevision.js";
8
+ export class CmsSdk {
9
+ constructor(config) {
10
+ this.config = config;
11
+ this.fetchFn = config.fetch || fetch;
12
+ }
13
+ async getEntry(params) {
14
+ return getEntryFn(this.config, this.fetchFn, params);
15
+ }
16
+ async listEntries(params) {
17
+ return listEntriesFn(this.config, this.fetchFn, params);
18
+ }
19
+ async createEntry(params) {
20
+ return createEntryFn(this.config, this.fetchFn, params);
21
+ }
22
+ async updateEntryRevision(params) {
23
+ return updateEntryRevisionFn(this.config, this.fetchFn, params);
24
+ }
25
+ async deleteEntryRevision(params) {
26
+ return deleteEntryRevisionFn(this.config, this.fetchFn, params);
27
+ }
28
+ async publishEntryRevision(params) {
29
+ return publishEntryRevisionFn(this.config, this.fetchFn, params);
30
+ }
31
+ async unpublishEntryRevision(params) {
32
+ return unpublishEntryRevisionFn(this.config, this.fetchFn, params);
33
+ }
34
+ }
35
+
36
+ //# sourceMappingURL=CmsSdk.js.map
package/CmsSdk.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getEntry","getEntryFn","listEntries","listEntriesFn","createEntry","createEntryFn","updateEntryRevision","updateEntryRevisionFn","deleteEntryRevision","deleteEntryRevisionFn","publishEntryRevision","publishEntryRevisionFn","unpublishEntryRevision","unpublishEntryRevisionFn","CmsSdk","constructor","config","fetchFn","fetch","params"],"sources":["CmsSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./methods/cms/cmsTypes.js\";\nimport type { GetEntryParams } from \"./methods/cms/getEntry.js\";\nimport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\nimport type { CreateEntryParams, CreateCmsEntryData } from \"./methods/cms/createEntry.js\";\nimport type {\n UpdateEntryRevisionParams,\n UpdateCmsEntryData\n} from \"./methods/cms/updateEntryRevision.js\";\nimport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\nimport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\nimport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getEntry as getEntryFn } from \"./methods/cms/getEntry.js\";\nimport { listEntries as listEntriesFn } from \"./methods/cms/listEntries.js\";\nimport { createEntry as createEntryFn } from \"./methods/cms/createEntry.js\";\nimport { updateEntryRevision as updateEntryRevisionFn } from \"./methods/cms/updateEntryRevision.js\";\nimport { deleteEntryRevision as deleteEntryRevisionFn } from \"./methods/cms/deleteEntryRevision.js\";\nimport { publishEntryRevision as publishEntryRevisionFn } from \"./methods/cms/publishEntryRevision.js\";\nimport { unpublishEntryRevision as unpublishEntryRevisionFn } from \"./methods/cms/unpublishEntryRevision.js\";\n\nexport class CmsSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: GetEntryParams\n ): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n return getEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n params: ListEntriesParams\n ): Promise<Result<ListEntriesResult<TValues>, HttpError | GraphQLError | NetworkError>> {\n return listEntriesFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async createEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: CreateEntryParams<TValues>\n ): Promise<Result<CreateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n return createEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UpdateEntryRevisionParams<TValues>\n ): Promise<Result<UpdateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n return updateEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async deleteEntryRevision(\n params: DeleteEntryRevisionParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return deleteEntryRevisionFn(this.config, this.fetchFn, params);\n }\n\n async publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: PublishEntryRevisionParams\n ): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n return publishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UnpublishEntryRevisionParams\n ): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n return unpublishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n}\n"],"mappings":"AAcA,SAASA,QAAQ,IAAIC,UAAU;AAC/B,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,mBAAmB,IAAIC,qBAAqB;AACrD,SAASC,mBAAmB,IAAIC,qBAAqB;AACrD,SAASC,oBAAoB,IAAIC,sBAAsB;AACvD,SAASC,sBAAsB,IAAIC,wBAAwB;AAE3D,OAAO,MAAMC,MAAM,CAAC;EAIhBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAMlB,QAAQA,CACVmB,MAAsB,EACyD;IAC/E,OAAOlB,UAAU,CAAU,IAAI,CAACe,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACjE;EAEA,MAAMjB,WAAWA,CACbiB,MAAyB,EAC2D;IACpF,OAAOhB,aAAa,CAAU,IAAI,CAACa,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACpE;EAEA,MAAMf,WAAWA,CACbe,MAAkC,EACmD;IACrF,OAAOd,aAAa,CAAU,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACpE;EAEA,MAAMb,mBAAmBA,CACrBa,MAA0C,EAC2C;IACrF,OAAOZ,qBAAqB,CAAU,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC5E;EAEA,MAAMX,mBAAmBA,CACrBW,MAAiC,EACgC;IACjE,OAAOV,qBAAqB,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACnE;EAEA,MAAMT,oBAAoBA,CACtBS,MAAkC,EAC6C;IAC/E,OAAOR,sBAAsB,CAAU,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC7E;EAEA,MAAMP,sBAAsBA,CACxBO,MAAoC,EAC2C;IAC/E,OAAON,wBAAwB,CAAU,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC/E;AACJ","ignoreList":[]}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/sdk
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/Result.d.ts ADDED
@@ -0,0 +1,102 @@
1
+ /**
2
+ * A container type that represents either a successful result (`ok`) or a failure (`fail`).
3
+ * Inspired by functional programming constructs like `Either` or `Result` in other languages.
4
+ *
5
+ * @template TValue - The type of the success value.
6
+ * @template TError - The type of the error value.
7
+ */
8
+ export declare class Result<TValue, TError = never> {
9
+ protected readonly _isOk: boolean;
10
+ protected readonly _value?: TValue;
11
+ protected readonly _error?: TError;
12
+ private constructor();
13
+ /**
14
+ * Creates a successful `Result` containing the provided value.
15
+ * If no value is provided, returns Result<void, never>.
16
+ *
17
+ * @param value - The value to wrap in a successful result (optional).
18
+ * @returns A `Result` instance with the value.
19
+ */
20
+ static ok<T>(value: T): Result<T, never>;
21
+ static ok(): Result<void, never>;
22
+ /**
23
+ * Creates a failed `Result` containing the provided error.
24
+ *
25
+ * @param error - The error to wrap in a failed result.
26
+ * @returns A `Result` instance with the error.
27
+ */
28
+ static fail<E>(error: E): Result<never, E>;
29
+ /**
30
+ * Checks whether the result is successful.
31
+ *
32
+ * @returns `true` if the result is `ok`, otherwise `false`.
33
+ * Acts as a type guard to narrow the type to a successful result.
34
+ */
35
+ isOk(): this is {
36
+ _value: TValue;
37
+ } & Result<TValue, TError>;
38
+ /**
39
+ * Checks whether the result is a failure.
40
+ *
41
+ * @returns `true` if the result is `fail`, otherwise `false`.
42
+ * Acts as a type guard to narrow the type to a failed result.
43
+ */
44
+ isFail(): this is {
45
+ _error: TError;
46
+ } & Result<TValue, TError>;
47
+ /**
48
+ * Gets the value inside a successful result.
49
+ *
50
+ * @throws If the result is a failure.
51
+ * @returns The success value.
52
+ */
53
+ get value(): TValue;
54
+ /**
55
+ * Gets the error inside a failed result.
56
+ *
57
+ * @throws If the result is successful.
58
+ * @returns The error value.
59
+ */
60
+ get error(): TError;
61
+ /**
62
+ * Transforms the success value using the provided mapping function.
63
+ *
64
+ * @template U - The type of the new success value.
65
+ * @param fn - Function to apply to the value if the result is successful.
66
+ * @returns A new `Result` containing the mapped value, or the original error if failed.
67
+ */
68
+ map<U>(fn: (value: TValue) => U): Result<U, TError>;
69
+ /**
70
+ * Transforms the error value using the provided mapping function.
71
+ *
72
+ * @template F - The type of the new error.
73
+ * @param fn - Function to apply to the error if the result is a failure.
74
+ * @returns A new `Result` containing the original value or the mapped error.
75
+ */
76
+ mapError<F>(fn: (error: TError) => F): Result<TValue, F>;
77
+ /**
78
+ * Chains another `Result`-producing function onto this result.
79
+ * If this result is successful, the function is applied to the value.
80
+ * If this result is a failure, the original error is returned.
81
+ *
82
+ * @template U - The type of the next success value.
83
+ * @param fn - A function that takes the current value and returns another `Result`.
84
+ * @returns A new `Result` from applying the function or the original failure.
85
+ */
86
+ flatMap<U>(fn: (value: TValue) => Result<U, TError>): Result<U, TError>;
87
+ /**
88
+ * Pattern-matches the result to handle both success and failure cases.
89
+ *
90
+ * @template U - The return type of both match functions.
91
+ * @param handlers - An object containing `ok` and `fail` handlers.
92
+ * @returns The return value from the corresponding handler.
93
+ */
94
+ match<U>(handlers: {
95
+ ok: (value: TValue) => U;
96
+ fail: (error: TError) => U;
97
+ }): U;
98
+ }
99
+ export declare namespace Result {
100
+ type UnwrapResult<T> = Awaited<T> extends Result<infer Ok, any> ? Ok : never;
101
+ type UnwrapError<T> = Awaited<T> extends Result<any, infer Err> ? Err : never;
102
+ }
package/Result.js ADDED
@@ -0,0 +1,143 @@
1
+ /**
2
+ * A container type that represents either a successful result (`ok`) or a failure (`fail`).
3
+ * Inspired by functional programming constructs like `Either` or `Result` in other languages.
4
+ *
5
+ * @template TValue - The type of the success value.
6
+ * @template TError - The type of the error value.
7
+ */
8
+ export class Result {
9
+ constructor(isOk, value, error) {
10
+ this._isOk = isOk;
11
+ this._value = value;
12
+ this._error = error;
13
+ }
14
+
15
+ /**
16
+ * Creates a successful `Result` containing the provided value.
17
+ * If no value is provided, returns Result<void, never>.
18
+ *
19
+ * @param value - The value to wrap in a successful result (optional).
20
+ * @returns A `Result` instance with the value.
21
+ */
22
+
23
+ static ok(value) {
24
+ return new Result(true, value);
25
+ }
26
+
27
+ /**
28
+ * Creates a failed `Result` containing the provided error.
29
+ *
30
+ * @param error - The error to wrap in a failed result.
31
+ * @returns A `Result` instance with the error.
32
+ */
33
+ static fail(error) {
34
+ return new Result(false, undefined, error);
35
+ }
36
+
37
+ /**
38
+ * Checks whether the result is successful.
39
+ *
40
+ * @returns `true` if the result is `ok`, otherwise `false`.
41
+ * Acts as a type guard to narrow the type to a successful result.
42
+ */
43
+ isOk() {
44
+ return this._isOk;
45
+ }
46
+
47
+ /**
48
+ * Checks whether the result is a failure.
49
+ *
50
+ * @returns `true` if the result is `fail`, otherwise `false`.
51
+ * Acts as a type guard to narrow the type to a failed result.
52
+ */
53
+ isFail() {
54
+ return !this._isOk;
55
+ }
56
+
57
+ /**
58
+ * Gets the value inside a successful result.
59
+ *
60
+ * @throws If the result is a failure.
61
+ * @returns The success value.
62
+ */
63
+ get value() {
64
+ if (!this._isOk) {
65
+ console.error(this.error);
66
+ throw new Error("Tried to get value from a failed Result.");
67
+ }
68
+ return this._value;
69
+ }
70
+
71
+ /**
72
+ * Gets the error inside a failed result.
73
+ *
74
+ * @throws If the result is successful.
75
+ * @returns The error value.
76
+ */
77
+ get error() {
78
+ if (this._isOk) {
79
+ throw new Error("Tried to get error from a successful Result.");
80
+ }
81
+ return this._error;
82
+ }
83
+
84
+ /**
85
+ * Transforms the success value using the provided mapping function.
86
+ *
87
+ * @template U - The type of the new success value.
88
+ * @param fn - Function to apply to the value if the result is successful.
89
+ * @returns A new `Result` containing the mapped value, or the original error if failed.
90
+ */
91
+ map(fn) {
92
+ if (this.isOk()) {
93
+ return Result.ok(fn(this._value));
94
+ }
95
+ return Result.fail(this._error);
96
+ }
97
+
98
+ /**
99
+ * Transforms the error value using the provided mapping function.
100
+ *
101
+ * @template F - The type of the new error.
102
+ * @param fn - Function to apply to the error if the result is a failure.
103
+ * @returns A new `Result` containing the original value or the mapped error.
104
+ */
105
+ mapError(fn) {
106
+ if (this.isFail()) {
107
+ return Result.fail(fn(this._error));
108
+ }
109
+ return Result.ok(this._value);
110
+ }
111
+
112
+ /**
113
+ * Chains another `Result`-producing function onto this result.
114
+ * If this result is successful, the function is applied to the value.
115
+ * If this result is a failure, the original error is returned.
116
+ *
117
+ * @template U - The type of the next success value.
118
+ * @param fn - A function that takes the current value and returns another `Result`.
119
+ * @returns A new `Result` from applying the function or the original failure.
120
+ */
121
+ flatMap(fn) {
122
+ if (this.isOk()) {
123
+ return fn(this._value);
124
+ }
125
+ return Result.fail(this._error);
126
+ }
127
+
128
+ /**
129
+ * Pattern-matches the result to handle both success and failure cases.
130
+ *
131
+ * @template U - The return type of both match functions.
132
+ * @param handlers - An object containing `ok` and `fail` handlers.
133
+ * @returns The return value from the corresponding handler.
134
+ */
135
+ match(handlers) {
136
+ if (this.isOk()) {
137
+ return handlers.ok(this._value);
138
+ }
139
+ return handlers.fail(this._error);
140
+ }
141
+ }
142
+
143
+ //# sourceMappingURL=Result.js.map
package/Result.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","constructor","isOk","value","error","_isOk","_value","_error","ok","fail","undefined","isFail","console","Error","map","fn","mapError","flatMap","match","handlers"],"sources":["Result.ts"],"sourcesContent":["/**\n * A container type that represents either a successful result (`ok`) or a failure (`fail`).\n * Inspired by functional programming constructs like `Either` or `Result` in other languages.\n *\n * @template TValue - The type of the success value.\n * @template TError - The type of the error value.\n */\nexport class Result<TValue, TError = never> {\n protected readonly _isOk: boolean;\n protected readonly _value?: TValue;\n protected readonly _error?: TError;\n\n private constructor(isOk: boolean, value?: TValue, error?: TError) {\n this._isOk = isOk;\n this._value = value;\n this._error = error;\n }\n\n /**\n * Creates a successful `Result` containing the provided value.\n * If no value is provided, returns Result<void, never>.\n *\n * @param value - The value to wrap in a successful result (optional).\n * @returns A `Result` instance with the value.\n */\n public static ok<T>(value: T): Result<T, never>;\n public static ok(): Result<void, never>;\n public static ok<T>(value?: T): Result<T | void, never> {\n return new Result<T | void, never>(true, value);\n }\n\n /**\n * Creates a failed `Result` containing the provided error.\n *\n * @param error - The error to wrap in a failed result.\n * @returns A `Result` instance with the error.\n */\n public static fail<E>(error: E): Result<never, E> {\n return new Result<never, E>(false, undefined, error);\n }\n\n /**\n * Checks whether the result is successful.\n *\n * @returns `true` if the result is `ok`, otherwise `false`.\n * Acts as a type guard to narrow the type to a successful result.\n */\n public isOk(): this is { _value: TValue } & Result<TValue, TError> {\n return this._isOk;\n }\n\n /**\n * Checks whether the result is a failure.\n *\n * @returns `true` if the result is `fail`, otherwise `false`.\n * Acts as a type guard to narrow the type to a failed result.\n */\n public isFail(): this is { _error: TError } & Result<TValue, TError> {\n return !this._isOk;\n }\n\n /**\n * Gets the value inside a successful result.\n *\n * @throws If the result is a failure.\n * @returns The success value.\n */\n public get value(): TValue {\n if (!this._isOk) {\n console.error(this.error);\n throw new Error(\"Tried to get value from a failed Result.\");\n }\n\n return this._value as TValue;\n }\n\n /**\n * Gets the error inside a failed result.\n *\n * @throws If the result is successful.\n * @returns The error value.\n */\n public get error(): TError {\n if (this._isOk) {\n throw new Error(\"Tried to get error from a successful Result.\");\n }\n\n return this._error as TError;\n }\n\n /**\n * Transforms the success value using the provided mapping function.\n *\n * @template U - The type of the new success value.\n * @param fn - Function to apply to the value if the result is successful.\n * @returns A new `Result` containing the mapped value, or the original error if failed.\n */\n public map<U>(fn: (value: TValue) => U): Result<U, TError> {\n if (this.isOk()) {\n return Result.ok(fn(this._value as TValue));\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Transforms the error value using the provided mapping function.\n *\n * @template F - The type of the new error.\n * @param fn - Function to apply to the error if the result is a failure.\n * @returns A new `Result` containing the original value or the mapped error.\n */\n public mapError<F>(fn: (error: TError) => F): Result<TValue, F> {\n if (this.isFail()) {\n return Result.fail(fn(this._error as TError));\n }\n\n return Result.ok(this._value as TValue);\n }\n\n /**\n * Chains another `Result`-producing function onto this result.\n * If this result is successful, the function is applied to the value.\n * If this result is a failure, the original error is returned.\n *\n * @template U - The type of the next success value.\n * @param fn - A function that takes the current value and returns another `Result`.\n * @returns A new `Result` from applying the function or the original failure.\n */\n public flatMap<U>(fn: (value: TValue) => Result<U, TError>): Result<U, TError> {\n if (this.isOk()) {\n return fn(this._value as TValue);\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Pattern-matches the result to handle both success and failure cases.\n *\n * @template U - The return type of both match functions.\n * @param handlers - An object containing `ok` and `fail` handlers.\n * @returns The return value from the corresponding handler.\n */\n public match<U>(handlers: { ok: (value: TValue) => U; fail: (error: TError) => U }): U {\n if (this.isOk()) {\n return handlers.ok(this._value as TValue);\n }\n\n return handlers.fail(this._error as TError);\n }\n}\n\nexport namespace Result {\n export type UnwrapResult<T> = Awaited<T> extends Result<infer Ok, any> ? Ok : never;\n export type UnwrapError<T> = Awaited<T> extends Result<any, infer Err> ? Err : never;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,MAAM,CAAyB;EAKhCC,WAAWA,CAACC,IAAa,EAAEC,KAAc,EAAEC,KAAc,EAAE;IAC/D,IAAI,CAACC,KAAK,GAAGH,IAAI;IACjB,IAAI,CAACI,MAAM,GAAGH,KAAK;IACnB,IAAI,CAACI,MAAM,GAAGH,KAAK;EACvB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;;EAGI,OAAcI,EAAEA,CAAIL,KAAS,EAA2B;IACpD,OAAO,IAAIH,MAAM,CAAkB,IAAI,EAAEG,KAAK,CAAC;EACnD;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,OAAcM,IAAIA,CAAIL,KAAQ,EAAoB;IAC9C,OAAO,IAAIJ,MAAM,CAAW,KAAK,EAAEU,SAAS,EAAEN,KAAK,CAAC;EACxD;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACWF,IAAIA,CAAA,EAAwD;IAC/D,OAAO,IAAI,CAACG,KAAK;EACrB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACWM,MAAMA,CAAA,EAAwD;IACjE,OAAO,CAAC,IAAI,CAACN,KAAK;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,IAAWF,KAAKA,CAAA,EAAW;IACvB,IAAI,CAAC,IAAI,CAACE,KAAK,EAAE;MACbO,OAAO,CAACR,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;MACzB,MAAM,IAAIS,KAAK,CAAC,0CAA0C,CAAC;IAC/D;IAEA,OAAO,IAAI,CAACP,MAAM;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,IAAWF,KAAKA,CAAA,EAAW;IACvB,IAAI,IAAI,CAACC,KAAK,EAAE;MACZ,MAAM,IAAIQ,KAAK,CAAC,8CAA8C,CAAC;IACnE;IAEA,OAAO,IAAI,CAACN,MAAM;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWO,GAAGA,CAAIC,EAAwB,EAAqB;IACvD,IAAI,IAAI,CAACb,IAAI,CAAC,CAAC,EAAE;MACb,OAAOF,MAAM,CAACQ,EAAE,CAACO,EAAE,CAAC,IAAI,CAACT,MAAgB,CAAC,CAAC;IAC/C;IAEA,OAAON,MAAM,CAACS,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC7C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWS,QAAQA,CAAID,EAAwB,EAAqB;IAC5D,IAAI,IAAI,CAACJ,MAAM,CAAC,CAAC,EAAE;MACf,OAAOX,MAAM,CAACS,IAAI,CAACM,EAAE,CAAC,IAAI,CAACR,MAAgB,CAAC,CAAC;IACjD;IAEA,OAAOP,MAAM,CAACQ,EAAE,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC3C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACWW,OAAOA,CAAIF,EAAwC,EAAqB;IAC3E,IAAI,IAAI,CAACb,IAAI,CAAC,CAAC,EAAE;MACb,OAAOa,EAAE,CAAC,IAAI,CAACT,MAAgB,CAAC;IACpC;IAEA,OAAON,MAAM,CAACS,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC7C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWW,KAAKA,CAAIC,QAAkE,EAAK;IACnF,IAAI,IAAI,CAACjB,IAAI,CAAC,CAAC,EAAE;MACb,OAAOiB,QAAQ,CAACX,EAAE,CAAC,IAAI,CAACF,MAAgB,CAAC;IAC7C;IAEA,OAAOa,QAAQ,CAACV,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC/C;AACJ","ignoreList":[]}
package/Webiny.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { WebinyConfig } from "./types.js";
2
+ import { CmsSdk } from "./CmsSdk.js";
3
+ export declare class Webiny {
4
+ readonly cms: CmsSdk;
5
+ constructor(config: WebinyConfig);
6
+ }
7
+ export { Webiny as Sdk };
8
+ export type { WebinyConfig as SdkConfig };
package/Webiny.js ADDED
@@ -0,0 +1,14 @@
1
+ import { CmsSdk } from "./CmsSdk.js";
2
+ export class Webiny {
3
+ constructor(config) {
4
+ this.cms = new CmsSdk({
5
+ ...config,
6
+ tenant: config.tenant || "root"
7
+ });
8
+ }
9
+ }
10
+
11
+ // Backward compatibility exports.
12
+ export { Webiny as Sdk };
13
+
14
+ //# sourceMappingURL=Webiny.js.map
package/Webiny.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsSdk","Webiny","constructor","config","cms","tenant","Sdk"],"sources":["Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n\n constructor(config: WebinyConfig) {\n this.cms = new CmsSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n }\n}\n\n// Backward compatibility exports.\nexport { Webiny as Sdk };\nexport type { WebinyConfig as SdkConfig };\n"],"mappings":"AACA,SAASA,MAAM;AAEf,OAAO,MAAMC,MAAM,CAAC;EAGhBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACC,GAAG,GAAG,IAAIJ,MAAM,CAAC;MAClB,GAAGG,MAAM;MACTE,MAAM,EAAEF,MAAM,CAACE,MAAM,IAAI;IAC7B,CAAC,CAAC;EACN;AACJ;;AAEA;AACA,SAASJ,MAAM,IAAIK,GAAG","ignoreList":[]}
package/errors.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { BaseError } from "./BaseError.js";
2
+ type HttpErrorData = {
3
+ status: number;
4
+ };
5
+ /**
6
+ * HTTP error from the API.
7
+ */
8
+ export declare class HttpError extends BaseError<HttpErrorData> {
9
+ readonly code: "HTTP_ERROR";
10
+ constructor(status: number, message: string);
11
+ }
12
+ type GraphQLErrorData = {
13
+ code?: string;
14
+ };
15
+ /**
16
+ * GraphQL error from the API.
17
+ */
18
+ export declare class GraphQLError extends BaseError<GraphQLErrorData> {
19
+ readonly code: "GRAPHQL_ERROR";
20
+ constructor(message: string, errorCode?: string);
21
+ }
22
+ /**
23
+ * Network error (fetch failed).
24
+ */
25
+ export declare class NetworkError extends BaseError {
26
+ readonly code: "NETWORK_ERROR";
27
+ constructor(message: string);
28
+ }
29
+ export {};
package/errors.js ADDED
@@ -0,0 +1,43 @@
1
+ import { BaseError } from "./BaseError.js";
2
+ /**
3
+ * HTTP error from the API.
4
+ */
5
+ export class HttpError extends BaseError {
6
+ code = "HTTP_ERROR";
7
+ constructor(status, message) {
8
+ super({
9
+ message,
10
+ data: {
11
+ status
12
+ }
13
+ });
14
+ }
15
+ }
16
+ /**
17
+ * GraphQL error from the API.
18
+ */
19
+ export class GraphQLError extends BaseError {
20
+ code = "GRAPHQL_ERROR";
21
+ constructor(message, errorCode) {
22
+ super({
23
+ message,
24
+ data: {
25
+ code: errorCode
26
+ }
27
+ });
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Network error (fetch failed).
33
+ */
34
+ export class NetworkError extends BaseError {
35
+ code = "NETWORK_ERROR";
36
+ constructor(message) {
37
+ super({
38
+ message
39
+ });
40
+ }
41
+ }
42
+
43
+ //# sourceMappingURL=errors.js.map
package/errors.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BaseError","HttpError","code","constructor","status","message","data","GraphQLError","errorCode","NetworkError"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"./BaseError.js\";\n\ntype HttpErrorData = {\n status: number;\n};\n\n/**\n * HTTP error from the API.\n */\nexport class HttpError extends BaseError<HttpErrorData> {\n override readonly code = \"HTTP_ERROR\" as const;\n\n constructor(status: number, message: string) {\n super({\n message,\n data: { status }\n });\n }\n}\n\ntype GraphQLErrorData = {\n code?: string;\n};\n\n/**\n * GraphQL error from the API.\n */\nexport class GraphQLError extends BaseError<GraphQLErrorData> {\n override readonly code = \"GRAPHQL_ERROR\" as const;\n\n constructor(message: string, errorCode?: string) {\n super({\n message,\n data: { code: errorCode }\n });\n }\n}\n\n/**\n * Network error (fetch failed).\n */\nexport class NetworkError extends BaseError {\n override readonly code = \"NETWORK_ERROR\" as const;\n\n constructor(message: string) {\n super({\n message\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAMlB;AACA;AACA;AACA,OAAO,MAAMC,SAAS,SAASD,SAAS,CAAgB;EAClCE,IAAI,GAAG,YAAY;EAErCC,WAAWA,CAACC,MAAc,EAAEC,OAAe,EAAE;IACzC,KAAK,CAAC;MACFA,OAAO;MACPC,IAAI,EAAE;QAAEF;MAAO;IACnB,CAAC,CAAC;EACN;AACJ;AAMA;AACA;AACA;AACA,OAAO,MAAMG,YAAY,SAASP,SAAS,CAAmB;EACxCE,IAAI,GAAG,eAAe;EAExCC,WAAWA,CAACE,OAAe,EAAEG,SAAkB,EAAE;IAC7C,KAAK,CAAC;MACFH,OAAO;MACPC,IAAI,EAAE;QAAEJ,IAAI,EAAEM;MAAU;IAC5B,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAAST,SAAS,CAAC;EACtBE,IAAI,GAAG,eAAe;EAExCC,WAAWA,CAACE,OAAe,EAAE;IACzB,KAAK,CAAC;MACFA;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export * from "./Webiny.js";
2
+ export * from "./CmsSdk.js";
3
+ export * from "./types.js";
4
+ export { Result } from "./Result.js";
5
+ export { HttpError, GraphQLError, NetworkError } from "./errors.js";
6
+ export type { CmsEntryValues, CmsEntryStatus, CmsIdentity, IEntryState, CmsEntryData } from "./methods/cms/cmsTypes.js";
7
+ export type { CreateCmsEntryData, CreateEntryParams } from "./methods/cms/createEntry.js";
8
+ export type { UpdateCmsEntryData, UpdateEntryRevisionParams } from "./methods/cms/updateEntryRevision.js";
9
+ export type { GetEntryParams, GetEntryWhere } from "./methods/cms/getEntry.js";
10
+ export type { ListEntriesParams, ListEntriesResult } from "./methods/cms/listEntries.js";
11
+ export type { DeleteEntryRevisionParams } from "./methods/cms/deleteEntryRevision.js";
12
+ export type { PublishEntryRevisionParams } from "./methods/cms/publishEntryRevision.js";
13
+ export type { UnpublishEntryRevisionParams } from "./methods/cms/unpublishEntryRevision.js";
package/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./Webiny.js";
2
+ export * from "./CmsSdk.js";
3
+ export * from "./types.js";
4
+ export { Result } from "./Result.js";
5
+ export { HttpError, GraphQLError, NetworkError } from "./errors.js";
6
+
7
+ // Export shared CMS types.
8
+
9
+ // Export types from methods.
10
+
11
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","HttpError","GraphQLError","NetworkError"],"sources":["index.ts"],"sourcesContent":["export * from \"./Webiny.js\";\nexport * from \"./CmsSdk.js\";\nexport * from \"./types.js\";\nexport { Result } from \"./Result.js\";\nexport { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\n\n// Export shared CMS types.\nexport type {\n CmsEntryValues,\n CmsEntryStatus,\n CmsIdentity,\n IEntryState,\n CmsEntryData\n} from \"./methods/cms/cmsTypes.js\";\n\n// Export types from methods.\nexport type { CreateCmsEntryData, CreateEntryParams } from \"./methods/cms/createEntry.js\";\n\nexport type {\n UpdateCmsEntryData,\n UpdateEntryRevisionParams\n} from \"./methods/cms/updateEntryRevision.js\";\n\nexport type { GetEntryParams, GetEntryWhere } from \"./methods/cms/getEntry.js\";\n\nexport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\n\nexport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\n\nexport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\n\nexport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM;AACf,SAASC,SAAS,EAAEC,YAAY,EAAEC,YAAY;;AAE9C;;AASA","ignoreList":[]}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Entry values type.
3
+ */
4
+ export interface CmsEntryValues {
5
+ [key: string]: any;
6
+ }
7
+ /**
8
+ * Entry status type.
9
+ */
10
+ export type CmsEntryStatus = "published" | "unpublished" | "draft";
11
+ /**
12
+ * CMS identity.
13
+ */
14
+ export interface CmsIdentity {
15
+ /**
16
+ * ID of the user.
17
+ */
18
+ id: string;
19
+ /**
20
+ * Full name of the user.
21
+ */
22
+ displayName: string;
23
+ /**
24
+ * Type of the user (admin, user).
25
+ */
26
+ type: string;
27
+ }
28
+ /**
29
+ * Entry state.
30
+ */
31
+ export interface IEntryState {
32
+ state: string;
33
+ workflowId: string;
34
+ stepId: string;
35
+ stepName: string;
36
+ }
37
+ /**
38
+ * CMS entry data returned from queries.
39
+ */
40
+ export interface CmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {
41
+ id?: string;
42
+ entryId?: string;
43
+ status?: CmsEntryStatus;
44
+ /**
45
+ * Entry-level meta fields.
46
+ */
47
+ createdOn?: Date | string;
48
+ modifiedOn?: Date | string | null;
49
+ savedOn?: Date | string;
50
+ deletedOn?: Date | string | null;
51
+ restoredOn?: Date | string | null;
52
+ createdBy?: CmsIdentity;
53
+ modifiedBy?: CmsIdentity;
54
+ savedBy?: CmsIdentity;
55
+ deletedBy?: CmsIdentity | null;
56
+ restoredBy?: CmsIdentity | null;
57
+ firstPublishedOn?: Date | string;
58
+ lastPublishedOn?: Date | string;
59
+ firstPublishedBy?: CmsIdentity;
60
+ lastPublishedBy?: CmsIdentity;
61
+ /**
62
+ * Revision-level meta fields.
63
+ */
64
+ revisionCreatedOn?: Date | string;
65
+ revisionModifiedOn?: Date | string | null;
66
+ revisionSavedOn?: Date | string;
67
+ revisionDeletedOn?: Date | string | null;
68
+ revisionRestoredOn?: Date | string | null;
69
+ revisionCreatedBy?: CmsIdentity;
70
+ revisionModifiedBy?: CmsIdentity | null;
71
+ revisionSavedBy?: CmsIdentity;
72
+ revisionDeletedBy?: CmsIdentity | null;
73
+ revisionRestoredBy?: CmsIdentity | null;
74
+ revisionFirstPublishedOn?: Date | string;
75
+ revisionLastPublishedOn?: Date | string;
76
+ revisionFirstPublishedBy?: CmsIdentity;
77
+ revisionLastPublishedBy?: CmsIdentity;
78
+ location?: {
79
+ folderId?: string | null;
80
+ };
81
+ values?: TValues;
82
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=cmsTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["cmsTypes.ts"],"sourcesContent":["/**\n * Entry values type.\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\n/**\n * Entry status type.\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\n/**\n * CMS identity.\n */\nexport interface CmsIdentity {\n /**\n * ID of the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string;\n /**\n * Type of the user (admin, user).\n */\n type: string;\n}\n\n/**\n * Entry state.\n */\nexport interface IEntryState {\n state: string;\n workflowId: string;\n stepId: string;\n stepName: string;\n}\n\n/**\n * CMS entry data returned from queries.\n */\nexport interface CmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n entryId?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields.\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields.\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n location?: {\n folderId?: string | null;\n };\n\n values?: TValues;\n}\n"],"mappings":"","ignoreList":[]}