@squidcloud/backend 1.0.9 → 1.0.11

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,13 @@
1
+ import { ActionMethodDecorator, ActionType, ApiEndpointId, CollectionName, CronExpression, CronExpressionString, ExecutableAction, IntegrationId, QueryName, SchedulerAction, SchedulerId, SecureApiAction, SecureDatabaseAction, SecureExecutableAction, SecureGraphQLAction, SecureNamedQueryAction, TransformDatabaseAction, TriggerAction, TriggerId, WebhookAction, WebhookId } from '@squidcloud/common';
2
+ export declare function secureDatabase<T extends ActionType>(type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
3
+ export declare function secureCollection<T extends ActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<SecureDatabaseAction<T>>;
4
+ export declare function secureExecutable(executable: string): ActionMethodDecorator<SecureExecutableAction>;
5
+ export declare function secureApi<T extends SecureApiAction>(integrationId: IntegrationId, endpointId?: ApiEndpointId): ActionMethodDecorator<SecureApiAction>;
6
+ export declare function secureGraphQL<T extends SecureGraphQLAction>(integrationId: IntegrationId): ActionMethodDecorator<SecureGraphQLAction>;
7
+ export declare function transformCollection<T extends ActionType>(collectionName: CollectionName, type: T, integrationId?: IntegrationId): ActionMethodDecorator<TransformDatabaseAction<T>>;
8
+ export declare function executable(): ActionMethodDecorator<ExecutableAction>;
9
+ export declare function trigger(id: TriggerId, collectionName: CollectionName, integrationId?: IntegrationId): ActionMethodDecorator<TriggerAction>;
10
+ export declare function scheduler(id: SchedulerId, cronExpression: CronExpression | CronExpressionString): ActionMethodDecorator<SchedulerAction>;
11
+ export declare function webhook(id: WebhookId): ActionMethodDecorator<WebhookAction>;
12
+ export declare function namedQuery(integrationId: string, name: string): any;
13
+ export declare function secureNamedQuery<T extends SecureNamedQueryAction>(integrationId: IntegrationId, queryName: QueryName): ActionMethodDecorator<SecureNamedQueryAction>;
@@ -0,0 +1,3 @@
1
+ export * from './actions';
2
+ export * from './project';
3
+ export * from './service';
@@ -0,0 +1,234 @@
1
+ import { ActionType, ApiEndpointId, ApplicationBundleData, CollectionName, FunctionName, IntegrationId, QueryName, SchedulerId, ServiceFunctionName, TriggerId, WebhookId } from '@squidcloud/common';
2
+ declare class Meta {
3
+ data: ApplicationBundleData;
4
+ /**
5
+ * @secureDatabase("read", "ExampleIntegration")
6
+ *
7
+ * Applying the decorator above to the myMethod method on the MyService
8
+ * class will generate the following metadata:
9
+ *
10
+ * data: {
11
+ * databases: {
12
+ * ExampleIntegration: {
13
+ * security: {
14
+ * read: ['MyService:myMethod']
15
+ * }
16
+ * }
17
+ * }
18
+ * }
19
+ */
20
+ secureDatabase(type: ActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
21
+ /**
22
+ * @secureCollection("ExampleCollection", "read", "ExampleIntegration")
23
+ *
24
+ * Applying the decorator above to the myMethod method on the MyService
25
+ * class will generate the following metadata:
26
+ *
27
+ * data: {
28
+ * databases: {
29
+ * ExampleIntegration: {
30
+ * collections: {
31
+ * ExampleCollection: {
32
+ * security: {
33
+ * read: ['MyService:myMethod']
34
+ * }
35
+ * }
36
+ * }
37
+ * }
38
+ * }
39
+ * }
40
+ */
41
+ secureCollection(collectionName: CollectionName, type: ActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
42
+ /**
43
+ * @secureExecutable("myExecutable")
44
+ *
45
+ * Applying the decorator above to the myMethod method on the MyService
46
+ * class will generate the following metadata:
47
+ *
48
+ * data: {
49
+ * executables: {
50
+ * myExecutable: {
51
+ * security: ['MyService:myMethod']
52
+ * }
53
+ * }
54
+ * }
55
+ */
56
+ secureExecutable(executable: FunctionName, serviceFunction: ServiceFunctionName): void;
57
+ /**
58
+ * @secureApi("ExampleIntegration", "myEndpoint")
59
+ *
60
+ * Applying the decorator above to the myMethod method on the MyService
61
+ * class will generate the following metadata:
62
+ *
63
+ * data: {
64
+ * apis: {
65
+ * ExampleIntegration: {
66
+ * myEndpoint: {
67
+ * security: ['MyService:myMethod']
68
+ * }
69
+ * }
70
+ * }
71
+ * }
72
+ */
73
+ secureApi(integrationId: IntegrationId, endpointId: ApiEndpointId | undefined, serviceFunction: ServiceFunctionName): void;
74
+ /**
75
+ * @secureGraphQL("ExampleIntegration")
76
+ *
77
+ * Applying the decorator above to the myMethod method on the MyService
78
+ * class will generate the following metadata:
79
+ *
80
+ * data: {
81
+ * graphql: {
82
+ * ExampleIntegration: {
83
+ * security: ['MyService:myMethod']
84
+ * }
85
+ * }
86
+ * }
87
+ */
88
+ secureGraphQL(integrationId: IntegrationId, serviceFunction: ServiceFunctionName): void;
89
+ /**
90
+ * @transformDatabase(""read", "ExampleIntegration")
91
+ *
92
+ * Applying the decorator above to the myMethod method on the MyService
93
+ * class will generate the following metadata:
94
+ *
95
+ * data: {
96
+ * databases: {
97
+ * ExampleIntegration: {
98
+ * transform: {
99
+ * read: {
100
+ * type: "read"
101
+ * functionName: "MyService:myMethod"
102
+ * }
103
+ * }
104
+ * }
105
+ * }
106
+ * }
107
+ */
108
+ transformDatabase(type: ActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
109
+ /**
110
+ * @transformCollection("ExampleCollection", "read", "ExampleIntegration")
111
+ *
112
+ * Applying the decorator above to the myMethod method on the MyService
113
+ * class will generate the following metadata:
114
+ *
115
+ * data: {
116
+ * databases: {
117
+ * ExampleIntegration: {
118
+ * collections: {
119
+ * ExampleCollection: {
120
+ * transform: {
121
+ * read: {
122
+ * type: "read"
123
+ * functionName: "MyService:myMethod"
124
+ * }
125
+ * }
126
+ * }
127
+ * }
128
+ * }
129
+ * }
130
+ * }
131
+ */
132
+ transformCollection(collectionName: CollectionName, type: ActionType, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
133
+ /**
134
+ * @executable()
135
+ *
136
+ * Applying the decorator above to the myMethod method on the MyService
137
+ * class will generate the following metadata:
138
+ *
139
+ * data: {
140
+ * executables: {
141
+ * myExecutable: {
142
+ * serviceName: "MyService:myMethod",
143
+ * }
144
+ * }
145
+ * }
146
+ */
147
+ executable(serviceFunction: ServiceFunctionName): void;
148
+ /**
149
+ * @trigger("my-trigger", "ExampleCollection", "ExampleIntegration")
150
+ *
151
+ * Applying the decorator above to the myMethod method on the MyService
152
+ * class will generate the following metadata:
153
+ *
154
+ * data: {
155
+ * triggers: {
156
+ * "my-trigger": {
157
+ * integrationId: "ExampleIntegration"
158
+ * collectionName: "ExampleCollection"
159
+ * functionName: "MyService:myMethod",
160
+ * }
161
+ * }
162
+ * }
163
+ */
164
+ trigger(id: TriggerId, collectionName: CollectionName, serviceFunction: ServiceFunctionName, integrationId?: IntegrationId): void;
165
+ /**
166
+ * @scheduler("my-scheduler", "CronExpression")
167
+ *
168
+ * Applying the decorator above to the myMethod method on the MyService
169
+ * class will generate the following metadata:
170
+ *
171
+ * data: {
172
+ * schedulers: {
173
+ * "my-scheduler", {
174
+ * cronExpression: "CronExpression"
175
+ * functionName: "MyService:myMethod",
176
+ * }
177
+ * }
178
+ * }
179
+ */
180
+ scheduler(id: SchedulerId, cronExpression: string, serviceFunction: ServiceFunctionName): void;
181
+ /**
182
+ * @webhook("my-webhook")
183
+ *
184
+ * Applying the decorator above to the myMethod method on the MyService
185
+ * class will generate the following metadata:
186
+ *
187
+ * data: {
188
+ * webhooks: {
189
+ * "my-webhook", {
190
+ * functionName: "MyService:myMethod",
191
+ * }
192
+ * }
193
+ * }
194
+ */
195
+ webhook(id: WebhookId, serviceFunction: ServiceFunctionName): void;
196
+ /**
197
+ * @namedQuery('exampleIntegration', 'my-query')
198
+ * static myQuery = "select * from my-table where id = ${id}";
199
+ *
200
+ * Applying the decorator above to the myQuery static string in MyService
201
+ * class will generate the following metadata:
202
+ *
203
+ *
204
+ *
205
+ * data: {
206
+ * namedQueries: {
207
+ * "exampleIntegration", {
208
+ * my-query: {
209
+ * queryString: "select * from my-table where id = $id"
210
+ * }
211
+ * }
212
+ * }
213
+ * }
214
+ */
215
+ namedQuery(integrationId: IntegrationId, name: QueryName, queryString: string): void;
216
+ /**
217
+ * @secureNamedQuery("exampleIntegration", "queryName")
218
+ *
219
+ * Applying the decorator above to the myMethod method on the MyService
220
+ * class will generate the following metadata:
221
+ *
222
+ * data: {
223
+ * namedQueries: {
224
+ * exampleIntegration: {
225
+ * queryName: {
226
+ * security: MyService:myMethod
227
+ * }
228
+ * }
229
+ * }
230
+ */
231
+ secureNamedQuery(integrationId: IntegrationId, name: QueryName, serviceFunction: ServiceFunctionName): void;
232
+ }
233
+ export declare const metadata: Meta;
234
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare class SquidProject {
2
+ private metadata;
3
+ private cleanup;
4
+ }
@@ -0,0 +1,18 @@
1
+ import { Squid } from '@squidcloud/client';
2
+ import { AuthWithApiKey, AuthWithBearer, Logger, RunContext, SecretKey, SecretValue, ServiceConfig, SupportedSquidRegion, WebhookResponse } from '@squidcloud/common';
3
+ export declare class SquidService {
4
+ readonly secrets: Record<SecretKey, SecretValue>;
5
+ readonly logger: Logger;
6
+ private readonly backendApiKey;
7
+ readonly context: RunContext;
8
+ readonly codeDir: string;
9
+ readonly region: SupportedSquidRegion;
10
+ private readonly auth;
11
+ constructor(config: ServiceConfig);
12
+ get squid(): Squid;
13
+ get assetsDirectory(): string;
14
+ getUserAuth(): AuthWithBearer | undefined;
15
+ getApiKeyAuth(): AuthWithApiKey | undefined;
16
+ isAuthenticated(): boolean;
17
+ createWebhookResponse(body?: any, statusCode?: number, headers?: Record<string, any>): WebhookResponse;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/backend",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Squid Cloud's backend SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/backend/src/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "publish:public": "npm version patch && npm run build && npm publish --access public"
11
11
  },
12
12
  "files": [
13
- "dist/index.js"
13
+ "dist/index.js",
14
+ "dist/backend"
14
15
  ],
15
16
  "keywords": [],
16
17
  "author": "",