@devvit/shared-types 0.12.0-next-2025-04-30-2e2a14dbe.0 → 0.12.0-next-2025-08-12-20-19-11-8d352335b.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/AdsMetadata.d.ts +6 -0
- package/AdsMetadata.d.ts.map +1 -0
- package/AdsMetadata.js +5 -0
- package/Assets.d.ts +0 -2
- package/Assets.d.ts.map +1 -1
- package/Assets.js +0 -2
- package/CircuitBreaker.d.ts.map +1 -1
- package/Config.d.ts +3 -3
- package/Config.d.ts.map +1 -1
- package/ConfigImpl.d.ts +8 -8
- package/ConfigImpl.d.ts.map +1 -1
- package/ConfigImpl.js +22 -31
- package/Header.d.ts +1 -0
- package/Header.d.ts.map +1 -1
- package/Header.js +1 -0
- package/PostData.d.ts +8 -0
- package/PostData.d.ts.map +1 -0
- package/ProjectTemplateInfo.d.ts +21 -0
- package/ProjectTemplateInfo.d.ts.map +1 -0
- package/ProjectTemplateInfo.js +10 -0
- package/client/emit-effect.d.ts +24 -0
- package/client/emit-effect.d.ts.map +1 -0
- package/client/emit-effect.js +56 -0
- package/client/emit-effect.test.d.ts.map +1 -0
- package/client/share.d.ts +3 -0
- package/client/share.d.ts.map +1 -0
- package/client/share.js +2 -0
- package/constants.d.ts +9 -0
- package/constants.d.ts.map +1 -1
- package/constants.js +9 -0
- package/fetch-domains.d.ts +14 -0
- package/fetch-domains.d.ts.map +1 -0
- package/fetch-domains.js +42 -0
- package/fetch-domains.test.d.ts.map +1 -0
- package/isDevvitDependency.js +1 -1
- package/json.d.ts +12 -12
- package/package.json +18 -13
- package/richtext/index.d.ts +6 -0
- package/richtext/index.d.ts.map +1 -0
- package/richtext/index.js +1 -0
- package/schemas/config-file.v1.d.ts +272 -0
- package/schemas/config-file.v1.d.ts.map +1 -0
- package/schemas/config-file.v1.js +254 -0
- package/schemas/config-file.v1.json +683 -0
- package/schemas/config-file.v1.test.d.ts.map +1 -0
- package/schemas/constants.d.ts +4 -0
- package/schemas/constants.d.ts.map +1 -0
- package/schemas/constants.js +3 -0
- package/{payments/products.schema.json → schemas/products.json} +1 -1
- package/{payments/productSchemaJSONValidator.d.ts → schemas/productsSchemaJSONValidator.d.ts} +2 -2
- package/schemas/productsSchemaJSONValidator.d.ts.map +1 -0
- package/{payments/productSchemaJSONValidator.js → schemas/productsSchemaJSONValidator.js} +1 -1
- package/schemas/productsSchemaJSONValidator.test.d.ts.map +1 -0
- package/server/get-devvit-config.d.ts +7 -0
- package/server/get-devvit-config.d.ts.map +1 -0
- package/server/get-devvit-config.js +10 -0
- package/shared/devvit-worker-global.d.ts +47 -0
- package/shared/devvit-worker-global.d.ts.map +1 -0
- package/shared/devvit-worker-global.js +7 -0
- package/{forms/types.d.ts → shared/form.d.ts} +16 -72
- package/shared/form.d.ts.map +1 -0
- package/tid.d.ts +26 -32
- package/tid.d.ts.map +1 -1
- package/tid.js +43 -62
- package/web-view-scripts-constants.d.ts +14 -0
- package/web-view-scripts-constants.d.ts.map +1 -0
- package/web-view-scripts-constants.js +13 -0
- package/forms/assertValidFormFields.d.ts +0 -11
- package/forms/assertValidFormFields.d.ts.map +0 -1
- package/forms/assertValidFormFields.js +0 -29
- package/forms/assertValidFormFields.test.d.ts.map +0 -1
- package/forms/getFormValues.d.ts +0 -6
- package/forms/getFormValues.d.ts.map +0 -1
- package/forms/getFormValues.js +0 -31
- package/forms/getFormValues.test.d.ts.map +0 -1
- package/forms/transformForm.d.ts +0 -4
- package/forms/transformForm.d.ts.map +0 -1
- package/forms/transformForm.js +0 -141
- package/forms/transformForm.test.d.ts.map +0 -1
- package/forms/types.d.ts.map +0 -1
- package/index.d.ts +0 -2
- package/index.d.ts.map +0 -1
- package/payments/index.d.ts +0 -4
- package/payments/index.d.ts.map +0 -1
- package/payments/index.js +0 -3
- package/payments/productSchemaJSONValidator.d.ts.map +0 -1
- package/payments/productSchemaJSONValidator.test.d.ts.map +0 -1
- /package/{index.js → PostData.js} +0 -0
- /package/{forms/types.js → shared/form.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/schemas/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"id": "https://developers.reddit.com/
|
|
3
|
+
"$id": "https://developers.reddit.com/schema/products.json",
|
|
4
4
|
"title": "Devvit Payments - Product Schema",
|
|
5
5
|
"description": "Schema for Devvit products",
|
|
6
6
|
"type": "object",
|
package/{payments/productSchemaJSONValidator.d.ts → schemas/productsSchemaJSONValidator.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Product } from '
|
|
1
|
+
import type { Product } from '../payments/Product.js';
|
|
2
2
|
/**
|
|
3
3
|
* This function validates the `products.json` file of a devvit project and returns the parsed
|
|
4
4
|
* objects
|
|
5
5
|
*/
|
|
6
6
|
export declare function validateProductsJSON(json: unknown): Product[];
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=productsSchemaJSONValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productsSchemaJSONValidator.d.ts","sourceRoot":"","sources":["../../src/schemas/productsSchemaJSONValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,CAO7D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jsonschema from 'jsonschema/lib/index.js';
|
|
2
|
-
import productSchema from './products.
|
|
2
|
+
import productSchema from './products.json' with { type: 'json' };
|
|
3
3
|
/**
|
|
4
4
|
* This function validates the `products.json` file of a devvit project and returns the parsed
|
|
5
5
|
* objects
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productsSchemaJSONValidator.test.d.ts","sourceRoot":"","sources":["../../src/schemas/productsSchemaJSONValidator.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-devvit-config.d.ts","sourceRoot":"","sources":["../../src/server/get-devvit-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAOxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the Config object that the runtime drops on globalThis. For internal use only.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export function getDevvitConfig() {
|
|
6
|
+
if (!globalThis.devvit?.config) {
|
|
7
|
+
throw new Error('Devvit config is not available. Make sure to call getDevvitConfig() after the Devvit runtime has been initialized.');
|
|
8
|
+
}
|
|
9
|
+
return globalThis.devvit.config;
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workers are expected to implement the MessagePort type where = onmessage()
|
|
3
|
+
* is the worker ingress / runtime egress and postMessage() is the worker
|
|
4
|
+
* egress / runtime ingress. See WorkerDispatcher.bindToWorkerPort() references
|
|
5
|
+
* for where the runtime-worker bidirectional connection is established.
|
|
6
|
+
*/
|
|
7
|
+
import type { Metadata } from '@devvit/protos';
|
|
8
|
+
import type { AssetMap } from '../Assets.js';
|
|
9
|
+
import type { Config } from '../Config.js';
|
|
10
|
+
import type { AppConfig } from '../schemas/config-file.v1.js';
|
|
11
|
+
import type { FormField } from './form.js';
|
|
12
|
+
declare global {
|
|
13
|
+
var devvit: DevvitWorkerGlobal | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* State initialized by the bootstrap (local runtime or compute) or `Devvit`
|
|
17
|
+
* singleton.
|
|
18
|
+
*
|
|
19
|
+
* Webbit apps have two copies of the Devvit singleton in two bundles
|
|
20
|
+
* (concatenated JavaScript): 1) blocks.template.ts 2) `@devvit/*` package
|
|
21
|
+
* dependencies on `@devvit/public-api`. Only the first is actually constructed
|
|
22
|
+
* by the classic bootstrap. The second is referenced indirectly by API calls
|
|
23
|
+
* like `BlocksHandler` but static state is never initialized.
|
|
24
|
+
*/
|
|
25
|
+
export type DevvitWorkerGlobal = {
|
|
26
|
+
/** Available to Webbit apps only. Initialized by `Devvit` singleton. */
|
|
27
|
+
appConfig?: AppConfig;
|
|
28
|
+
/** Initialized by `Devvit` singleton. */
|
|
29
|
+
assets?: AssetMap;
|
|
30
|
+
/** See bundle.template.cjs and PlatformUtil. Initialized by bootstrap. */
|
|
31
|
+
compute?: {
|
|
32
|
+
platform: 'web' | 'go' | 'node';
|
|
33
|
+
};
|
|
34
|
+
/** Nullish until initialized by bootloader. */
|
|
35
|
+
config?: Config;
|
|
36
|
+
/**
|
|
37
|
+
* Provide a way for webbit apps to manage their own async local storage for
|
|
38
|
+
* metadata. Initialized by bootstrap.
|
|
39
|
+
*/
|
|
40
|
+
metadataProvider?: () => Readonly<Metadata> | undefined;
|
|
41
|
+
/** Initialized by `Devvit` singleton. */
|
|
42
|
+
settings?: {
|
|
43
|
+
app?: FormField[] | undefined;
|
|
44
|
+
installation?: FormField[] | undefined;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=devvit-worker-global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devvit-worker-global.d.ts","sourceRoot":"","sources":["../../src/shared/devvit-worker-global.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC5C;AAKD;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wEAAwE;IACxE,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,yCAAyC;IACzC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAGlB,0EAA0E;IAC1E,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,CAAA;KAAE,CAAC;IAE9C,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAExD,yCAAyC;IACzC,QAAQ,CAAC,EAAE;QACT,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;QAC9B,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;KACxC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workers are expected to implement the MessagePort type where = onmessage()
|
|
3
|
+
* is the worker ingress / runtime egress and postMessage() is the worker
|
|
4
|
+
* egress / runtime ingress. See WorkerDispatcher.bindToWorkerPort() references
|
|
5
|
+
* for where the runtime-worker bidirectional connection is established.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { FieldConfig_Boolean, FieldConfig_Number, FieldConfig_Paragraph, FieldConfig_Selection, FieldConfig_Selection_Item, FieldConfig_String } from '@devvit/protos';
|
|
2
|
-
import type {
|
|
2
|
+
import type { JsonObject } from '../json.js';
|
|
3
3
|
import type { Prettify } from '../Prettify.js';
|
|
4
|
-
export type FormValues =
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export type FormValues<T extends JsonObject> = T;
|
|
5
|
+
export type FormRequest<T extends JsonObject> = T;
|
|
6
|
+
export type Form = {
|
|
7
|
+
/** The fields that will be displayed in the form */
|
|
8
|
+
fields: readonly FormField[];
|
|
9
|
+
/** An optional title for the form */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** An optional description for the form */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** An optional label for the submit button */
|
|
14
|
+
acceptLabel?: string;
|
|
15
|
+
/** An optional label for the cancel button */
|
|
16
|
+
cancelLabel?: string;
|
|
8
17
|
};
|
|
9
18
|
export type BaseField<ValueType> = {
|
|
10
19
|
/**
|
|
@@ -72,75 +81,10 @@ export type FormFieldGroup = {
|
|
|
72
81
|
/** The label of the group that will be displayed to the user */
|
|
73
82
|
label: string;
|
|
74
83
|
/** The fields that will be displayed in the group */
|
|
75
|
-
fields:
|
|
84
|
+
fields: FormField[];
|
|
76
85
|
/** An optional help text that will be displayed below the group */
|
|
77
86
|
helpText?: string | undefined;
|
|
78
87
|
required?: never;
|
|
79
88
|
};
|
|
80
89
|
export type FormField = StringField | ImageField | ParagraphField | NumberField | BooleanField | SelectField | FormFieldGroup;
|
|
81
|
-
|
|
82
|
-
/** The fields that will be displayed in the form */
|
|
83
|
-
fields: readonly FormField[];
|
|
84
|
-
/** An optional title for the form */
|
|
85
|
-
title?: string;
|
|
86
|
-
/** An optional description for the form */
|
|
87
|
-
description?: string;
|
|
88
|
-
/** An optional label for the submit button */
|
|
89
|
-
acceptLabel?: string;
|
|
90
|
-
/** An optional label for the cancel button */
|
|
91
|
-
cancelLabel?: string;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* A function that returns a form. You can use this to dynamically generate a form.
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* const formKey = Devvit.createForm((data) => ({
|
|
98
|
-
* fields: data.fields,
|
|
99
|
-
* title: data.title,
|
|
100
|
-
* }), callback);
|
|
101
|
-
*
|
|
102
|
-
* ...
|
|
103
|
-
*
|
|
104
|
-
* ui.showForm(formKey, {
|
|
105
|
-
* fields: [{ type: 'string', name: 'title', label: 'Title' }]
|
|
106
|
-
* title: 'My dynamic form'
|
|
107
|
-
* });
|
|
108
|
-
* ```
|
|
109
|
-
* */
|
|
110
|
-
export type FormFunction<T extends {
|
|
111
|
-
[key: string]: any;
|
|
112
|
-
} = {
|
|
113
|
-
[key: string]: any;
|
|
114
|
-
}> = (data: T) => Form;
|
|
115
|
-
export type FormToFormValues<T extends Form | FormFunction = Form | FormFunction> = FormFieldsToFormValues<(T extends FormFunction ? ReturnType<T> : T)['fields']>;
|
|
116
|
-
/**
|
|
117
|
-
* Input is a FormField[], output is a
|
|
118
|
-
* {fieldNameA: fieldTypeA, fieldNameB: fieldTypeB}.
|
|
119
|
-
*/
|
|
120
|
-
type FormFieldsToFormValues<T extends readonly FormField[]> = T extends readonly [
|
|
121
|
-
infer Field extends FormField,
|
|
122
|
-
...infer Rest extends FormField[]
|
|
123
|
-
] ? FormFieldToFormValue<Field> & FormFieldsToFormValues<Rest> : {
|
|
124
|
-
[key: string]: any;
|
|
125
|
-
};
|
|
126
|
-
/** Input is a FormField, output is a {fieldName: fieldType}. */
|
|
127
|
-
type FormFieldToFormValue<T extends FormField> = T extends BooleanField ? {
|
|
128
|
-
[_ in T['name']]: boolean;
|
|
129
|
-
} : T extends ImageField | ParagraphField | StringField ? FormFieldToRequiredFormValue<T, string> : T extends NumberField ? FormFieldToRequiredFormValue<T, number> : T extends SelectField ? {
|
|
130
|
-
[_ in T['name']]: string[];
|
|
131
|
-
} : T extends FormFieldGroup ? FormFieldsToFormValues<T['fields']> : never;
|
|
132
|
-
/**
|
|
133
|
-
* Input is a FormField, output is a {fieldName: fieldType} or
|
|
134
|
-
* {fieldName?: fieldType}.
|
|
135
|
-
*/
|
|
136
|
-
type FormFieldToRequiredFormValue<T extends ImageField | ParagraphField | StringField | NumberField, V> = T extends {
|
|
137
|
-
required: true;
|
|
138
|
-
} | {
|
|
139
|
-
defaultValue: boolean | number | string;
|
|
140
|
-
} ? {
|
|
141
|
-
[_ in T['name']]: V;
|
|
142
|
-
} : {
|
|
143
|
-
[_ in T['name']]?: V;
|
|
144
|
-
};
|
|
145
|
-
export {};
|
|
146
|
-
//# sourceMappingURL=types.d.ts.map
|
|
90
|
+
//# sourceMappingURL=form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/shared/form.ts"],"names":[],"mappings":"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"}
|
package/tid.d.ts
CHANGED
|
@@ -7,41 +7,35 @@ export declare enum T_PREFIX {
|
|
|
7
7
|
AWARD = "t6_"
|
|
8
8
|
}
|
|
9
9
|
/** Commment thing ID. */
|
|
10
|
-
export type
|
|
10
|
+
export type T1 = `${T_PREFIX.COMMENT}${string}`;
|
|
11
11
|
/** Account thing ID. */
|
|
12
|
-
export type
|
|
12
|
+
export type T2 = `${T_PREFIX.ACCOUNT}${string}`;
|
|
13
13
|
/** Post (also called link) thing ID. */
|
|
14
|
-
export type
|
|
14
|
+
export type T3 = `${T_PREFIX.LINK}${string}`;
|
|
15
15
|
/** Message thing ID. */
|
|
16
|
-
export type
|
|
16
|
+
export type T4 = `${T_PREFIX.MESSAGE}${string}`;
|
|
17
17
|
/** Subreddit thing ID. */
|
|
18
|
-
export type
|
|
18
|
+
export type T5 = `${T_PREFIX.SUBREDDIT}${string}`;
|
|
19
19
|
/** Award thing ID. */
|
|
20
|
-
export type
|
|
21
|
-
export type
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function
|
|
40
|
-
export declare function
|
|
41
|
-
export declare function isCommentId(id: string): boolean;
|
|
42
|
-
export declare function isAccountId(id: string): boolean;
|
|
43
|
-
export declare function isLinkId(id: string): boolean;
|
|
44
|
-
export declare function isMessageId(id: string): boolean;
|
|
45
|
-
export declare function isSubredditId(id: string): boolean;
|
|
46
|
-
export declare function isAwardId(id: string): boolean;
|
|
20
|
+
export type T6 = `${T_PREFIX.AWARD}${string}`;
|
|
21
|
+
export type Tid = T1 | T2 | T3 | T4 | T5 | T6;
|
|
22
|
+
export declare function isT1(id: string): id is T1;
|
|
23
|
+
export declare function isT2(id: string): id is T2;
|
|
24
|
+
export declare function isT3(id: string): id is T3;
|
|
25
|
+
export declare function isT4(id: string): id is T4;
|
|
26
|
+
export declare function isT5(id: string): id is T5;
|
|
27
|
+
export declare function isT6(id: string): id is T6;
|
|
28
|
+
export declare function assertT1(id: string): asserts id is T1;
|
|
29
|
+
export declare function assertT2(id: string): asserts id is T2;
|
|
30
|
+
export declare function assertT3(id: string): asserts id is T3;
|
|
31
|
+
export declare function assertT4(id: string): asserts id is T4;
|
|
32
|
+
export declare function assertT5(id: string): asserts id is T5;
|
|
33
|
+
export declare function assertT6(id: string): asserts id is T6;
|
|
34
|
+
export declare function T1(id: string): T1;
|
|
35
|
+
export declare function T2(id: string): T2;
|
|
36
|
+
export declare function T3(id: string): T3;
|
|
37
|
+
export declare function T4(id: string): T4;
|
|
38
|
+
export declare function T5(id: string): T5;
|
|
39
|
+
export declare function T6(id: string): T6;
|
|
40
|
+
export declare function asTid<T extends Tid>(id: string): T;
|
|
47
41
|
//# sourceMappingURL=tid.d.ts.map
|
package/tid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tid.d.ts","sourceRoot":"","sources":["../src/tid.ts"],"names":[],"mappings":"AAGA,oBAAY,QAAQ;IAClB,OAAO,QAAQ;IACf,OAAO,QAAQ;IACf,IAAI,QAAQ,CAAE,eAAe;IAC7B,OAAO,QAAQ;IACf,SAAS,QAAQ;IACjB,KAAK,QAAQ;CACd;AAGD,yBAAyB;AACzB,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"tid.d.ts","sourceRoot":"","sources":["../src/tid.ts"],"names":[],"mappings":"AAGA,oBAAY,QAAQ;IAClB,OAAO,QAAQ;IACf,OAAO,QAAQ;IACf,IAAI,QAAQ,CAAE,eAAe;IAC7B,OAAO,QAAQ;IACf,SAAS,QAAQ;IACjB,KAAK,QAAQ;CACd;AAGD,yBAAyB;AACzB,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC;AAChD,wBAAwB;AACxB,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC;AAChD,wCAAwC;AACxC,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC;AAC7C,wBAAwB;AACxB,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC;AAChD,0BAA0B;AAC1B,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;AAClD,sBAAsB;AACtB,MAAM,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,KAAK,GAAG,MAAM,EAAE,CAAC;AAE9C,MAAM,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAG9C,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,CAEzC;AAGD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AACD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AACD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AACD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AACD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AACD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAErD;AAGD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AACD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AACD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AACD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AACD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AACD,wBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,CAGjC;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAsBlD"}
|
package/tid.js
CHANGED
|
@@ -10,105 +10,86 @@ export var T_PREFIX;
|
|
|
10
10
|
T_PREFIX["AWARD"] = "t6_";
|
|
11
11
|
})(T_PREFIX || (T_PREFIX = {}));
|
|
12
12
|
// type guards
|
|
13
|
-
export function
|
|
13
|
+
export function isT1(id) {
|
|
14
14
|
return id.startsWith(T_PREFIX.COMMENT);
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
16
|
+
export function isT2(id) {
|
|
17
17
|
return id.startsWith(T_PREFIX.ACCOUNT);
|
|
18
18
|
}
|
|
19
|
-
export function
|
|
19
|
+
export function isT3(id) {
|
|
20
20
|
return id.startsWith(T_PREFIX.LINK);
|
|
21
21
|
}
|
|
22
|
-
export function
|
|
22
|
+
export function isT4(id) {
|
|
23
23
|
return id.startsWith(T_PREFIX.MESSAGE);
|
|
24
24
|
}
|
|
25
|
-
export function
|
|
25
|
+
export function isT5(id) {
|
|
26
26
|
return id.startsWith(T_PREFIX.SUBREDDIT);
|
|
27
27
|
}
|
|
28
|
-
export function
|
|
28
|
+
export function isT6(id) {
|
|
29
29
|
return id.startsWith(T_PREFIX.AWARD);
|
|
30
30
|
}
|
|
31
31
|
// assertion functions
|
|
32
|
-
export function
|
|
33
|
-
assert(
|
|
32
|
+
export function assertT1(id) {
|
|
33
|
+
assert(isT1(id), `Expected comment id to start with ${T_PREFIX.COMMENT}, got ${id}}`);
|
|
34
34
|
}
|
|
35
|
-
export function
|
|
36
|
-
assert(
|
|
35
|
+
export function assertT2(id) {
|
|
36
|
+
assert(isT2(id), `Expected account id to start with ${T_PREFIX.ACCOUNT}, got ${id}}`);
|
|
37
37
|
}
|
|
38
|
-
export function
|
|
39
|
-
assert(
|
|
38
|
+
export function assertT3(id) {
|
|
39
|
+
assert(isT3(id), `Expected link id to start with ${T_PREFIX.LINK}, got ${id}}`);
|
|
40
40
|
}
|
|
41
|
-
export function
|
|
42
|
-
assert(
|
|
41
|
+
export function assertT4(id) {
|
|
42
|
+
assert(isT4(id), `Expected message id to start with ${T_PREFIX.MESSAGE}, got ${id}}`);
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
45
|
-
assert(
|
|
44
|
+
export function assertT5(id) {
|
|
45
|
+
assert(isT5(id), `Expected subreddit id to start with ${T_PREFIX.SUBREDDIT}, got ${id}}`);
|
|
46
46
|
}
|
|
47
|
-
export function
|
|
48
|
-
assert(
|
|
47
|
+
export function assertT6(id) {
|
|
48
|
+
assert(isT6(id), `Expected award id to start with ${T_PREFIX.AWARD}, got ${id}}`);
|
|
49
49
|
}
|
|
50
50
|
// factory functions
|
|
51
|
-
export function
|
|
52
|
-
|
|
51
|
+
export function T1(id) {
|
|
52
|
+
assertT1(id);
|
|
53
53
|
return id;
|
|
54
54
|
}
|
|
55
|
-
export function
|
|
56
|
-
|
|
55
|
+
export function T2(id) {
|
|
56
|
+
assertT2(id);
|
|
57
57
|
return id;
|
|
58
58
|
}
|
|
59
|
-
export function
|
|
60
|
-
|
|
59
|
+
export function T3(id) {
|
|
60
|
+
assertT3(id);
|
|
61
61
|
return id;
|
|
62
62
|
}
|
|
63
|
-
export function
|
|
64
|
-
|
|
63
|
+
export function T4(id) {
|
|
64
|
+
assertT4(id);
|
|
65
65
|
return id;
|
|
66
66
|
}
|
|
67
|
-
export function
|
|
68
|
-
|
|
67
|
+
export function T5(id) {
|
|
68
|
+
assertT5(id);
|
|
69
69
|
return id;
|
|
70
70
|
}
|
|
71
|
-
export function
|
|
72
|
-
|
|
71
|
+
export function T6(id) {
|
|
72
|
+
assertT6(id);
|
|
73
73
|
return id;
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
75
|
+
export function asTid(id) {
|
|
76
|
+
if (isT1(id)) {
|
|
77
|
+
return T1(id);
|
|
78
78
|
}
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
79
|
+
if (isT2(id)) {
|
|
80
|
+
return T2(id);
|
|
81
81
|
}
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
82
|
+
if (isT3(id)) {
|
|
83
|
+
return T3(id);
|
|
84
84
|
}
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
85
|
+
if (isT4(id)) {
|
|
86
|
+
return T4(id);
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
88
|
+
if (isT5(id)) {
|
|
89
|
+
return T5(id);
|
|
90
90
|
}
|
|
91
|
-
if (
|
|
92
|
-
return
|
|
91
|
+
if (isT6(id)) {
|
|
92
|
+
return T6(id);
|
|
93
93
|
}
|
|
94
94
|
throw new Error(`Expected thing id to start with ${Object.values(T_PREFIX).join(', ')} got ${id}}`);
|
|
95
95
|
}
|
|
96
|
-
// convenience functions
|
|
97
|
-
export function isCommentId(id) {
|
|
98
|
-
return isT1ID(id);
|
|
99
|
-
}
|
|
100
|
-
export function isAccountId(id) {
|
|
101
|
-
return isT2ID(id);
|
|
102
|
-
}
|
|
103
|
-
export function isLinkId(id) {
|
|
104
|
-
return isT3ID(id);
|
|
105
|
-
}
|
|
106
|
-
export function isMessageId(id) {
|
|
107
|
-
return isT4ID(id);
|
|
108
|
-
}
|
|
109
|
-
export function isSubredditId(id) {
|
|
110
|
-
return isT5ID(id);
|
|
111
|
-
}
|
|
112
|
-
export function isAwardId(id) {
|
|
113
|
-
return isT6ID(id);
|
|
114
|
-
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@devvit/client` version query parameter name the web view's document
|
|
3
|
+
* script tag:
|
|
4
|
+
*
|
|
5
|
+
* <script src="https://webview.devvit.net/scripts/devvit.v1.min.js?clientVersion=1.2.3"></script>
|
|
6
|
+
*
|
|
7
|
+
* The value is the version of `@devvit/client` bundled with the app.
|
|
8
|
+
* `@devvit/client` may have runtime dependencies on
|
|
9
|
+
* `@devvit/web-view-scripts` (`devvit.v1.min.js`) which is not bundled. The
|
|
10
|
+
* client version can be used to specialize behavior to match the static
|
|
11
|
+
* expectations of the `@devvit/client` version.
|
|
12
|
+
*/
|
|
13
|
+
export declare const clientVersionQueryParam: string;
|
|
14
|
+
//# sourceMappingURL=web-view-scripts-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-view-scripts-constants.d.ts","sourceRoot":"","sources":["../src/web-view-scripts-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@devvit/client` version query parameter name the web view's document
|
|
3
|
+
* script tag:
|
|
4
|
+
*
|
|
5
|
+
* <script src="https://webview.devvit.net/scripts/devvit.v1.min.js?clientVersion=1.2.3"></script>
|
|
6
|
+
*
|
|
7
|
+
* The value is the version of `@devvit/client` bundled with the app.
|
|
8
|
+
* `@devvit/client` may have runtime dependencies on
|
|
9
|
+
* `@devvit/web-view-scripts` (`devvit.v1.min.js`) which is not bundled. The
|
|
10
|
+
* client version can be used to specialize behavior to match the static
|
|
11
|
+
* expectations of the `@devvit/client` version.
|
|
12
|
+
*/
|
|
13
|
+
export const clientVersionQueryParam = 'clientVersion';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FormField } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Make sure that the form fields have unique names.
|
|
4
|
-
*
|
|
5
|
-
* This is a carbon copy of the assertValidFormFields function in the public-api package
|
|
6
|
-
* We copy it here so that webbit-client does not need to depend on public-api
|
|
7
|
-
* Any changes to this function should be reflected in the public-api version
|
|
8
|
-
*/
|
|
9
|
-
export declare function assertValidFormFields(fields: readonly FormField[], seenNames?: Set<string>): void;
|
|
10
|
-
export declare function assertAppSecretsOnly(fields: readonly FormField[]): void;
|
|
11
|
-
//# sourceMappingURL=assertValidFormFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertValidFormFields.d.ts","sourceRoot":"","sources":["../../src/forms/assertValidFormFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,SAAS,GAAE,GAAG,CAAC,MAAM,CAAa,GACjC,IAAI,CAiBN;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAMvE"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make sure that the form fields have unique names.
|
|
3
|
-
*
|
|
4
|
-
* This is a carbon copy of the assertValidFormFields function in the public-api package
|
|
5
|
-
* We copy it here so that webbit-client does not need to depend on public-api
|
|
6
|
-
* Any changes to this function should be reflected in the public-api version
|
|
7
|
-
*/
|
|
8
|
-
export function assertValidFormFields(fields, seenNames = new Set()) {
|
|
9
|
-
for (const field of fields) {
|
|
10
|
-
if (field.type === 'group') {
|
|
11
|
-
assertValidFormFields(field.fields, seenNames);
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const fieldName = field.name;
|
|
16
|
-
if (seenNames.has(fieldName)) {
|
|
17
|
-
throw new Error(`Duplicate field name: ${fieldName}`);
|
|
18
|
-
}
|
|
19
|
-
seenNames.add(fieldName);
|
|
20
|
-
}
|
|
21
|
-
assertAppSecretsOnly(fields);
|
|
22
|
-
}
|
|
23
|
-
export function assertAppSecretsOnly(fields) {
|
|
24
|
-
for (const field of fields) {
|
|
25
|
-
if (field.type === 'string' && field.isSecret && field.scope !== 'app') {
|
|
26
|
-
throw `Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${field.name}"`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertValidFormFields.test.d.ts","sourceRoot":"","sources":["../../src/forms/assertValidFormFields.test.ts"],"names":[],"mappings":""}
|
package/forms/getFormValues.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFormValues.d.ts","sourceRoot":"","sources":["../../src/forms/getFormValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA2B7C,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,GAAG,UAAU,CAMpF"}
|
package/forms/getFormValues.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { FormFieldType } from '@devvit/protos';
|
|
2
|
-
function flattenFormFieldValue(value) {
|
|
3
|
-
switch (value.fieldType) {
|
|
4
|
-
case FormFieldType.STRING:
|
|
5
|
-
return value.stringValue;
|
|
6
|
-
case FormFieldType.IMAGE:
|
|
7
|
-
// the string value is the URL
|
|
8
|
-
return value.stringValue;
|
|
9
|
-
case FormFieldType.PARAGRAPH:
|
|
10
|
-
return value.stringValue;
|
|
11
|
-
case FormFieldType.NUMBER:
|
|
12
|
-
return value.numberValue;
|
|
13
|
-
case FormFieldType.BOOLEAN:
|
|
14
|
-
return value.boolValue;
|
|
15
|
-
case FormFieldType.SELECTION:
|
|
16
|
-
return value.selectionValue?.values ?? [];
|
|
17
|
-
default:
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// This is a carbon copy of the transformFormFields function in the public-api package
|
|
22
|
-
// We copy it here so that webbit-client does not need to depend on public-api
|
|
23
|
-
// Any changes to this function should be reflected in the public-api version
|
|
24
|
-
export function getFormValues(results) {
|
|
25
|
-
return Object.keys(results).reduce((acc, key) => {
|
|
26
|
-
const val = flattenFormFieldValue(results[key]);
|
|
27
|
-
if (val !== undefined)
|
|
28
|
-
acc[key] = val;
|
|
29
|
-
return acc;
|
|
30
|
-
}, {});
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFormValues.test.d.ts","sourceRoot":"","sources":["../../src/forms/getFormValues.test.ts"],"names":[],"mappings":""}
|
package/forms/transformForm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformForm.d.ts","sourceRoot":"","sources":["../../src/forms/transformForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,KAAK,EAEV,SAAS,EAOV,MAAM,YAAY,CAAC;AAKpB,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,cAAc,EAAE,CAqBlF"}
|