@twintag/twintag-sdk 0.2.235-TTPL-1970-twintagsdk-397570c85978488f2e5cebf3cab22c0a2faa6217

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.
@@ -0,0 +1,224 @@
1
+ import { View, EmailRequest } from './view';
2
+ import { StructuredObject } from './structuredObject';
3
+ import { ListObject } from './listObject';
4
+ import { Twintag } from './twintag';
5
+ /**
6
+ * The project class allows you to interact with a Twintag project.
7
+ *
8
+ * To construct a project object you pass the API key you find
9
+ * on the Twintag project page. E.g.:
10
+ * ```
11
+ * let project = new Twintag.Project('<Project API key>')
12
+ * ```
13
+ */
14
+ export declare class Project {
15
+ /**
16
+ * The API key passed when constructing the project object.
17
+ */
18
+ readonly apiKey: string;
19
+ private client;
20
+ private projectId;
21
+ private _useCaching;
22
+ /**
23
+ * Create a project
24
+ *
25
+ * @param apiKey You'll find the API Key on the Twintag project page.
26
+ */
27
+ constructor(apiKey: string);
28
+ /**
29
+ * set caching host
30
+ * @param val
31
+ * @hidden
32
+ */
33
+ useCaching(val: boolean): void;
34
+ /**
35
+ * Create a bag, automatically linked to the project.
36
+ */
37
+ createBag(): Promise<View>;
38
+ /**
39
+ * Create a {@link View | view } object with project-level privileges.
40
+ * Your project API key is automatically used for all changes.
41
+ */
42
+ getView(qid: string): View;
43
+ /**
44
+ * Create a {@link Twintag | twintag } object with project-level privileges.
45
+ * Your project API key is automatically used for all changes.
46
+ */
47
+ getTwintag(qid: string): Twintag;
48
+ /**
49
+ * List the metadata of a all twintags within your project.
50
+ * @param lang: optional language value. Allowed inputs are "all" or any language defined in project languages. If no value is passed, then project's default language will be used for returning data
51
+ * @typeParam T The objects in the resulting array will be cast to this type.
52
+ */
53
+ getMetadata<T>(lang?: string): Promise<T[]>;
54
+ /**
55
+ * Create an object for the project. Returns a StructuredObject object on which various operations can be performed.
56
+ *
57
+ * @param objectName Name with which the object is to be created
58
+ * @param objectAPIName APIName with which the object is to be created
59
+ * @param isList Optional paramaeter to specify if the object is of list type. By default false is set as the value for this param.
60
+ * @param isGlobal Optional parameter to specify if the object is of global type. By default false is set as the value for this param.
61
+ * @param keyProperty Optional parameter to specify the key property for the object is. By default no key property will be created.
62
+ */
63
+ newObject(objectName: string, objectAPIName?: string, isList?: boolean, isGlobal?: boolean, keyProperty?: string, access?: Access): Promise<StructuredObject>;
64
+ /**
65
+ * Get an object by name. Returns a StructuredObject object on which various operations can be performed.
66
+ *
67
+ * @param objectAPIName APIName of the object
68
+ */
69
+ getObject(objectAPIName: string): Promise<StructuredObject>;
70
+ /**
71
+ * Delete an object by its name
72
+ *
73
+ * @param objectAPIName Name of the object
74
+ */
75
+ deleteObject(objectAPIName: string): Promise<void>;
76
+ /**
77
+ * Delete project twintag.
78
+ * @param viewId view id of the twintag to be deleted.
79
+ *
80
+ * Example:
81
+ * ```js
82
+ * await project.deleteTwintag('viewid')
83
+ * ```
84
+ */
85
+ deleteTwintag(viewID: string): Promise<void>;
86
+ /**
87
+ * Get an object for the view
88
+ *
89
+ * Required rights: owner.
90
+ *
91
+ * @param objectAPIName Name of the object
92
+ *
93
+ * @category Structured Data
94
+ */
95
+ object(objectAPIName: string): ListObject;
96
+ /**
97
+ * @internal
98
+ * Get project id for when caching is enabled
99
+ */
100
+ private getProjectId;
101
+ /**
102
+ * @internal
103
+ * @param url
104
+ */
105
+ private getURL;
106
+ /**
107
+ * Get bags in a project
108
+ */
109
+ getBags(): Promise<Bag[]>;
110
+ /**
111
+ * Sends email
112
+ *
113
+ * @param request EmailRequest object
114
+ *
115
+ * Example:
116
+ *
117
+ * You can call this method by passing {@link EmailRequest}:
118
+ * ```js
119
+ * await projectObj.sendToSubscribers({
120
+ * recepients: ["to@mail.com"]
121
+ * body: "email body"
122
+ * subject: "email subject"
123
+ * cc: ["cc@mail.com"]
124
+ * bcc: ["bcc@mail.com"]
125
+ * })
126
+ * ```
127
+ * @category Notifications
128
+ */
129
+ sendToSubscribers<T>(request: EmailRequest): Promise<T>;
130
+ /**
131
+ * Adds languages for a project.
132
+ * Example:
133
+ * ```js
134
+ * await project.setAllowedLanguages(['en','nl'])
135
+ * ```
136
+ *
137
+ * You can set default language for project in same function as well
138
+ * Example:
139
+ * ```js
140
+ * await project.setAllowedLanguages(['en','nl'], 'nl')
141
+ * ```
142
+ *
143
+ * @param request: array of languages
144
+ * @param defaultLanguage: optional
145
+ * @category Languages
146
+ */
147
+ setAllowedLanguages(request: string[], defaultLanguage?: string): Promise<Language[]>;
148
+ /**
149
+ * Get all allowed languages for a project.
150
+ * Example:
151
+ * ```js
152
+ * let res = await project.getAllowedLanguages()
153
+ * ```
154
+ * @returns Promise<string[]>
155
+ */
156
+ getAllowedLanguages(): Promise<Language[]>;
157
+ /**
158
+ * Sets default language for the project.
159
+ * Example:
160
+ * ```js
161
+ * await project.setDefaultLanguage('nl')
162
+ * ```
163
+ *
164
+ * @param request: default language.
165
+ * @category Languages
166
+ */
167
+ setDefaultLanguage<T>(request: string): Promise<Language>;
168
+ /**
169
+ * gets default language for the project.
170
+ * Example:
171
+ * ```js
172
+ * await project.getDefaultLanguage()
173
+ * ```
174
+ *
175
+ * @category Languages
176
+ */
177
+ getDefaultLanguage(): Promise<Language>;
178
+ }
179
+ /**
180
+ * This function validates tokens provided by twintag's authentication mechanism
181
+ * @returns boolean specifying whether token is valid or not.
182
+ */
183
+ export declare function isValidToken(secretId: string, token: string): Promise<boolean>;
184
+ interface Bag {
185
+ projectId: string;
186
+ viewId: string;
187
+ type: string;
188
+ path: string;
189
+ StorageQid: string;
190
+ }
191
+ /**
192
+ * Access definition for an object.
193
+ *
194
+ * eg:
195
+ * <Access>{
196
+ * read: [BagType.Download, BagType.Owner]
197
+ * }
198
+ *
199
+ * Above definition means Read access is available only for Download and Owner bags.
200
+ * Download and owner bags can't access the object.
201
+ */
202
+ export interface Access {
203
+ read?: BagType[];
204
+ insert?: BagType[];
205
+ update?: BagType[];
206
+ delete?: BagType[];
207
+ }
208
+ /**
209
+ * BagType: Enum for type of bag.
210
+ */
211
+ export declare enum BagType {
212
+ Download = "download",
213
+ Upload = "upload",
214
+ UploadDownload = "upload-download",
215
+ Owner = "owner"
216
+ }
217
+ /**
218
+ * Languages for a project
219
+ */
220
+ interface Language {
221
+ name: string;
222
+ apiName: string;
223
+ }
224
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Twintag SDK.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { OfflineRequest } from '@twintag/model';
7
+ /**
8
+ * SetHost allows you to overwrite the Twintag domain.
9
+ *
10
+ * @hidden
11
+ */
12
+ export declare function setHost(host: string): void;
13
+ /**
14
+ * SetAdminHost allows you to overwrite the Twintag administrative domain.
15
+ *
16
+ * @hidden
17
+ */
18
+ export declare function setAdminHost(host: string): void;
19
+ /**
20
+ * setCachingHost allows you to overwrite the Twintag caching domain.
21
+ *
22
+ * @hidden
23
+ */
24
+ export declare function setCachingHost(host: string): void;
25
+ /**
26
+ * retryRequest allows you to retry a cached/stored request
27
+ *
28
+ * @hidden
29
+ */
30
+ export declare function retryRequest(request: OfflineRequest): Promise<[unknown, import("./error.model").TwintagError]>;
@@ -0,0 +1,123 @@
1
+ import { Access } from './project';
2
+ /**
3
+ * StructuredObject class represents an object of a project.
4
+ * Operations like creating attributes, getting attributes can be informed.
5
+ */
6
+ export declare class StructuredObject {
7
+ $schemaScope?: string;
8
+ $qid?: string;
9
+ name: string;
10
+ apiName: string;
11
+ isList: boolean;
12
+ isGlobal: boolean;
13
+ keyProperty?: string;
14
+ access?: Access;
15
+ private _useCaching;
16
+ private client;
17
+ /**
18
+ * Create an object of StructuredObject
19
+ *
20
+ * @param apiKey You'll find the API Key on the Twintag project page.
21
+ */
22
+ constructor(apiKey: string, useCaching?: boolean);
23
+ /**
24
+ * Get the attributes of the object of the project. Returns the list of attributes.
25
+ */
26
+ getAttributes(): Promise<Attribute[]>;
27
+ /**
28
+ * Get a specific attribute by name
29
+ *
30
+ * @param attributeName Name of the attribute
31
+ */
32
+ getAttribute<attribute>(attributeName: string): Promise<attribute>;
33
+ /**
34
+ * Create a new attribute for the object of a project
35
+ *
36
+ * @param attributeName Name of the attribute
37
+ * @param type Type of the attribute. Use the {@link AttributeType | AttributeType} enum or "string" for string type, "number" for number type and "datetime" for a datetime type, "richtext" for rich text type, "file" for file type, "boolean" for boolean type
38
+ * @param positionBefore The apiName of the property before which the newly created property is placed
39
+ */
40
+ newAttribute(attributeName: string, type?: string | AttributeType, positionBefore?: string): Promise<Attribute>;
41
+ /**
42
+ * Delete a attribute for the object of a project
43
+ *
44
+ * @param attributeName Name of the attribute
45
+ */
46
+ deleteAttribute(attributeName: string): Promise<void>;
47
+ /**
48
+ * Update an attribute for an object of a project
49
+ *
50
+ * @param property The desired state of the attribute. $qid is required in the object
51
+ *
52
+ */
53
+ updateAttribute<attribute>(property: Attribute): Promise<attribute>;
54
+ /**
55
+ * Rename the object
56
+ * @param newName
57
+ */
58
+ rename(newName: string): Promise<StructuredObject>;
59
+ /**
60
+ * Update the key property of the object.
61
+ * If a attribute by the given name already exists, the attribute will be marked as key attribute.
62
+ * If the attribute by the given name doesnot exists, a new attribute will be created and marked as key attribute.
63
+ * If instances for the object already exist, key property for the object cannot be updated.
64
+ * @param attributeName
65
+ */
66
+ updateKeyAttribute(attributeName: string): Promise<StructuredObject>;
67
+ /**
68
+ * Update the access of the object.
69
+ */
70
+ updateAccess(access: Access): Promise<StructuredObject>;
71
+ /**
72
+ * Add translation column for an existing structured data object column
73
+ * @param langAttributes: indexed type. pass key value pair for language and corresponding column name (see example below)
74
+ * @param parent: api name of column for which translation column is being created
75
+ * Example
76
+ * ```js
77
+ * //first create column for which translation has to be added
78
+ * const col = await object.newAttribute('col name')
79
+ *
80
+ * let langAttr = {
81
+ * 'fr':'french column name',
82
+ * 'nl':'dutch column name'
83
+ * }
84
+ *
85
+ * const res = await object.addTranslationAttribute(langAttr, col.apiName)
86
+ * ```
87
+ * This will create 2 language columns, each for french and dutch language.
88
+ * @returns Promise<Attribute[]>
89
+ */
90
+ addTranslationAttribute(langAttributes: languageAttributes, parent: string): Promise<Attribute[]>;
91
+ private getTypeByName;
92
+ /**
93
+ * Get URL
94
+ * @internal
95
+ */
96
+ getURL(url: string, schemaScope?: string): string;
97
+ }
98
+ interface Attribute {
99
+ $schemaScope: string;
100
+ $object: string;
101
+ $qid: string;
102
+ name: string;
103
+ apiName: string;
104
+ type: number;
105
+ nextProperty: string;
106
+ parent: string;
107
+ language: string;
108
+ }
109
+ export interface languageAttributes {
110
+ [language: string]: string;
111
+ }
112
+ /**
113
+ * Types of attributes
114
+ */
115
+ export declare enum AttributeType {
116
+ String = "string",
117
+ Number = "number",
118
+ Datetime = "datetime",
119
+ Richtext = "richtext",
120
+ File = "file",
121
+ Boolean = "boolean"
122
+ }
123
+ export {};
@@ -0,0 +1,38 @@
1
+ import { ViewInit } from "./base";
2
+ /**
3
+ * The twintag class allows you to interact with a view into a twintag.
4
+ * A view is represented by a `qid`. This is the string you see in its url:
5
+ * `https://twintag.io/<qid>`.
6
+ * A twintag can have multiple views, each view can have different rights associated.
7
+ * For example: owner, download-only, upload-only, ...
8
+ *
9
+ * To construct a twintag object, you pass its QID, E.g.:
10
+ * ```
11
+ * let twintag = new Zaza.Twintag(viewId)
12
+ * ```
13
+ */
14
+ export declare class Twintag {
15
+ private _base;
16
+ /**
17
+ * Construct a view by its QID.
18
+ *
19
+ * @param init Internal parameter.
20
+ */
21
+ constructor(qid: string);
22
+ /**
23
+ * _setConfig allows us to pass internal state.
24
+ *
25
+ * @internal */
26
+ _setConfig(init: ViewInit): void;
27
+ /**
28
+ * Delete a project twintag along with its metadata (if any)
29
+ * This view instance should be generated with project.
30
+ *
31
+ * Example:
32
+ * ```js
33
+ * const vi = project.getView('viewid')
34
+ * await vi.deleteProjectTwintag()
35
+ * ```
36
+ */
37
+ deleteProjectTwintag(): Promise<void>;
38
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The twintag-sdk version.
3
+ */
4
+ export declare const VERSION = "0.2.235-TTPL-1970-twintagsdk-397570c85978488f2e5cebf3cab22c0a2faa6217";