@mxpicture/gcp-functions-generator 1.1.76 → 1.1.78

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.
@@ -1,5 +1,4 @@
1
- import { PackageJson } from "@mxpicture/build-api/types";
2
- import { DecoFileExtension, DecoFileType, DecoTargetType } from "@mxpicture/gcp-functions-common/decorator";
1
+ import { DecoFileExtension, DecoFileType } from "@mxpicture/gcp-functions-common/decorator";
3
2
  /**
4
3
  * Decomposed parts of a dot-separated decorator filename.
5
4
  */
@@ -15,14 +14,6 @@ export interface ExtractFileParts {
15
14
  /** Whether this file is a generated artifact. */
16
15
  generated?: boolean;
17
16
  }
18
- /**
19
- * Represents a target package with its location and parsed `package.json`.
20
- */
21
- export interface TargetPackage {
22
- targetType: DecoTargetType;
23
- filePath: string;
24
- pkg: PackageJson;
25
- }
26
17
  /**
27
18
  * Environment variables required by generators that produce deployment-aware code.
28
19
  */
@@ -32,7 +23,6 @@ export interface GeneratorEnv {
32
23
  region: string;
33
24
  /** The GCP service account email used by Cloud Functions. */
34
25
  serviceAccount: string;
35
- queueId: string;
36
26
  }
37
27
  export interface JobConfig {
38
28
  projectId: string;
@@ -55,10 +45,4 @@ export interface JobParams {
55
45
  runServiceName: string;
56
46
  runServiceRegion: string;
57
47
  }
58
- export interface TaskParams {
59
- targetUrl: string;
60
- days: number;
61
- payload?: string;
62
- taskId?: string;
63
- }
64
48
  //# sourceMappingURL=types.common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.common.d.ts","sourceRoot":"","sources":["../../src/common/types.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACf,MAAM,2CAA2C,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IA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;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions-generator",
3
- "version": "1.1.76",
3
+ "version": "1.1.78",
4
4
  "description": "Tools for google cloud functions",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -13,8 +13,7 @@
13
13
  "./common": "./dist/common/index.js",
14
14
  "./package.json": "./package.json",
15
15
  "./decorator": "./dist/decorator/index.js",
16
- "./generator": "./dist/generator/index.js",
17
- "./tasks": "./dist/tasks/index.js"
16
+ "./generator": "./dist/generator/index.js"
18
17
  },
19
18
  "files": [
20
19
  "dist"
@@ -36,11 +35,10 @@
36
35
  },
37
36
  "dependencies": {
38
37
  "@google-cloud/scheduler": "^5.3.1",
39
- "@google-cloud/tasks": "^6.2.1",
40
38
  "@mxpicture/build-api": "^0.2.59",
41
- "@mxpicture/gcp-functions-backend": "^1.1.76",
42
- "@mxpicture/gcp-functions-common": "^1.1.76",
43
- "@mxpicture/gcp-functions-frontend": "^1.1.76",
39
+ "@mxpicture/gcp-functions-backend": "^1.1.78",
40
+ "@mxpicture/gcp-functions-common": "^1.1.78",
41
+ "@mxpicture/gcp-functions-frontend": "^1.1.78",
44
42
  "google-auth-library": "^10.6.2",
45
43
  "googleapis": "^171.4.0",
46
44
  "json5": "^2.2.3"
@@ -1,28 +0,0 @@
1
- import { CloudTasksClient } from "@google-cloud/tasks";
2
- import { GeneratorEnv, TaskParams } from "../common/types.common.js";
3
- export declare const scheduleTask: (params: TaskParams, env: GeneratorEnv) => Promise<string | null>;
4
- export declare const rescheduleTask: (params: TaskParams & {
5
- taskId: string;
6
- }, env: GeneratorEnv) => Promise<string | null>;
7
- export declare class TaskHandler {
8
- protected readonly env: GeneratorEnv;
9
- protected tasksClient: CloudTasksClient;
10
- constructor(env: GeneratorEnv);
11
- reschedule(p: TaskParams & {
12
- taskId: string;
13
- }): Promise<string | null>;
14
- schedule(p: TaskParams): Promise<string | null>;
15
- /**
16
- * Returns a Date in UTC in the allowed window (23:00–06:00).
17
- * Strategy:
18
- * - base = now + days
19
- * - if base hour in [0..5] => keep base (rounded up to next 5 min)
20
- * - if base hour in [23] => keep base (rounded up to next 5 min)
21
- * - else => task at 23:30:00 UTC same date as base
22
- */
23
- computeNightScheduleTimeUtc(base: Date): Date;
24
- protected assertDays(days: number): void;
25
- taskPath(taskId: string): string;
26
- queuePath(): string;
27
- }
28
- //# sourceMappingURL=TaskHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskHandler.d.ts","sourceRoot":"","sources":["../../src/tasks/TaskHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAErE,eAAO,MAAM,YAAY,GACvB,QAAQ,UAAU,EAClB,KAAK,YAAY,KAChB,OAAO,CAAC,MAAM,GAAG,IAAI,CAA0C,CAAC;AAEnE,eAAO,MAAM,cAAc,GACzB,QAAQ,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACvC,KAAK,YAAY,KAChB,OAAO,CAAC,MAAM,GAAG,IAAI,CAA4C,CAAC;AAErE,qBAAa,WAAW;IAGH,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY;IAFvD,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAEF,GAAG,EAAE,YAAY;IAI1C,UAAU,CACrB,CAAC,EAAE,UAAU,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQZ,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAuC5D;;;;;;;OAOG;IACI,2BAA2B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAkBpD,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM;IAK1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAShC,SAAS,IAAI,MAAM;CAO3B"}
@@ -1,86 +0,0 @@
1
- import { CloudTasksClient } from "@google-cloud/tasks";
2
- export const scheduleTask = async (params, env) => new TaskHandler(env).schedule(params);
3
- export const rescheduleTask = async (params, env) => new TaskHandler(env).reschedule(params);
4
- export class TaskHandler {
5
- env;
6
- tasksClient;
7
- constructor(env) {
8
- this.env = env;
9
- this.tasksClient = new CloudTasksClient();
10
- }
11
- async reschedule(p) {
12
- try {
13
- const taskPath = this.taskPath(p.taskId);
14
- await this.tasksClient.deleteTask({ name: taskPath });
15
- }
16
- catch { }
17
- return this.schedule(p);
18
- }
19
- async schedule(p) {
20
- this.assertDays(p.days);
21
- const base = new Date(Date.now() + p.days * 24 * 60 * 60 * 1000);
22
- const targetAt = this.computeNightScheduleTimeUtc(base);
23
- const queuePath = this.queuePath();
24
- const taskPath = p.taskId ? this.taskPath(p.taskId) : null;
25
- let body = null;
26
- let headers = null;
27
- if (p.payload) {
28
- body = Buffer.from(p.payload, "utf8").toString("base64");
29
- headers = {
30
- "Content-Type": "application/json",
31
- };
32
- }
33
- const [task] = await this.tasksClient.createTask({
34
- parent: queuePath,
35
- task: {
36
- scheduleTime: { seconds: Math.floor(targetAt.getTime() / 1000) },
37
- name: taskPath,
38
- httpRequest: {
39
- httpMethod: "POST",
40
- url: p.targetUrl,
41
- headers,
42
- body,
43
- oidcToken: {
44
- serviceAccountEmail: this.env.serviceAccount,
45
- // Optional: set audience; often leave unset, or set to the URL depending on your auth expectations
46
- // audience: EXEC_ENDPOINT_URL,
47
- },
48
- },
49
- },
50
- });
51
- return task.name ?? null;
52
- }
53
- /**
54
- * Returns a Date in UTC in the allowed window (23:00–06:00).
55
- * Strategy:
56
- * - base = now + days
57
- * - if base hour in [0..5] => keep base (rounded up to next 5 min)
58
- * - if base hour in [23] => keep base (rounded up to next 5 min)
59
- * - else => task at 23:30:00 UTC same date as base
60
- */
61
- computeNightScheduleTimeUtc(base) {
62
- const d = new Date(base.getTime());
63
- const hour = d.getUTCHours();
64
- const inNight = hour >= 23 || hour < 6;
65
- if (!inNight) {
66
- d.setUTCHours(23, 30, 0, 0);
67
- return d;
68
- }
69
- // Round up to next 5 minutes to avoid "task in the past by milliseconds" issues
70
- const ms = d.getTime();
71
- const fiveMin = 5 * 60 * 1000;
72
- const rounded = Math.ceil(ms / fiveMin) * fiveMin;
73
- return new Date(rounded);
74
- }
75
- assertDays(days) {
76
- if (!Number.isInteger(days) || days < 1 || days > 100)
77
- throw new Error("days must be an integer between 1 and 100");
78
- }
79
- taskPath(taskId) {
80
- return this.tasksClient.taskPath(this.env.projectId, this.env.region, this.env.queueId, taskId);
81
- }
82
- queuePath() {
83
- return this.tasksClient.queuePath(this.env.projectId, this.env.region, this.env.queueId);
84
- }
85
- }
86
- //# sourceMappingURL=TaskHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskHandler.js","sourceRoot":"","sources":["../../src/tasks/TaskHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,MAAkB,EAClB,GAAiB,EACO,EAAE,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,MAAuC,EACvC,GAAiB,EACO,EAAE,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,OAAO,WAAW;IAGgB;IAF5B,WAAW,CAAmB;IAExC,YAAsC,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;QACrD,IAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,UAAU,CACrB,CAAkC;QAElC,IAAI,CA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AAG,GAAG;YACnD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IAEM,QAAQ,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAC9B,IAAI,CAAC,GAAG,CAAC,SAAS,EAClB,IAAI,CAAC,GAAG,CAAC,MAAM,EACf,IAAI,CAAC,GAAG,CAAC,OAAO,EAChB,MAAM,CACP,CAAC;IACJ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAC/B,IAAI,CAAC,GAAG,CAAC,SAAS,EAClB,IAAI,CAAC,GAAG,CAAC,MAAM,EACf,IAAI,CAAC,GAAG,CAAC,OAAO,CACjB,CAAC;IACJ,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TaskSetup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskSetup.d.ts","sourceRoot":"","sources":["../../src/tasks/TaskSetup.ts"],"names":[],"mappings":""}
@@ -1,173 +0,0 @@
1
- // not usable / untested!!!!!!!
2
- // import { CloudTasksClient } from "@google-cloud/tasks";
3
- // import {
4
- // GeneratorEnv,
5
- // TaskConfig,
6
- // TaskParams,
7
- // } from "../common/types.common.js";
8
- // import { google } from "googleapis";
9
- export {};
10
- // export class TaskSetup {
11
- // protected config: TaskConfig;
12
- // public constructor(
13
- // protected readonly params: TaskParams,
14
- // protected readonly env: GeneratorEnv,
15
- // ) {
16
- // this.config = this.prepareConfig(params, env);
17
- // }
18
- // public async run() {
19
- // const tasks = new CloudTasksClient();
20
- // const queueName = await this.ensureQueue(tasks);
21
- // const { saEmail } = await this.ensureServiceAccount();
22
- // console.log(`\nSummary`);
23
- // console.log(`- Project: ${this.config.projectId}`);
24
- // console.log(`- Region: ${this.config.region}`);
25
- // console.log(`- Queue: ${queueName}`);
26
- // console.log(`- Task OIDC service account: ${saEmail}`);
27
- // console.log(`- Exec endpoint: ${this.config.functionUrl}`);
28
- // // console.log(`- Dummy Firestore path (replace): ${DUMMY_FIRESTORE_DOC_PATH}`);
29
- // if (this.config.ensureRunInvokerBinding) {
30
- // // Best-effort guidance (automatic binding is hard without more info/permissions).
31
- // await this.tryGrantInvokerBinding(saEmail);
32
- // } else {
33
- // console.log(
34
- // `\nInvoker IAM not applied (APPLY_INVOKER_BINDING=false). You must grant roles/run.invoker to ${saEmail} for the target service.`,
35
- // );
36
- // }
37
- // }
38
- // protected prepareConfig(params: TaskParams, env: GeneratorEnv): TaskConfig {
39
- // const { projectId, region, serviceAccount } = env;
40
- // // If you prefer not to hardcode URL, pass FUNCTION_URL explicitly after deploy.
41
- // const functionUrl =
42
- // params.functionUrl ??
43
- // `https://${region}-${projectId}.cloudfunctions.net/${params.runServiceName}`;
44
- // return {
45
- // projectId,
46
- // region,
47
- // serviceAccount,
48
- // queueId: params.queueId ?? `${params.runServiceName}-task`,
49
- // functionUrl,
50
- // ensureRunInvokerBinding: !!params.ensureRunInvokerBinding,
51
- // runServiceName: params.runServiceName,
52
- // runServiceRegion: region,
53
- // };
54
- // }
55
- // public async ensureQueue(tasks: CloudTasksClient) {
56
- // const parent = tasks.locationPath(
57
- // this.config.projectId,
58
- // this.config.region,
59
- // );
60
- // const queueName = tasks.queuePath(
61
- // this.config.projectId,
62
- // this.config.region,
63
- // this.config.queueId,
64
- // );
65
- // try {
66
- // await tasks.getQueue({ name: queueName });
67
- // console.log(`Queue exists: ${queueName}`);
68
- // return queueName;
69
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- // } catch (e: any) {
71
- // // Not found => create
72
- // if (String(e?.code) !== "5") {
73
- // console.warn(`getQueue error (continuing to create):`, e?.message || e);
74
- // }
75
- // }
76
- // const [queue] = await tasks.createQueue({
77
- // parent,
78
- // queue: {
79
- // name: queueName,
80
- // // These defaults are fine; tune as desired.
81
- // rateLimits: {
82
- // maxDispatchesPerSecond: 1,
83
- // maxConcurrentDispatches: 1,
84
- // },
85
- // retryConfig: {
86
- // maxAttempts: 10,
87
- // minBackoff: { seconds: 10 },
88
- // maxBackoff: { seconds: 3600 },
89
- // maxDoublings: 5,
90
- // },
91
- // },
92
- // });
93
- // console.log(`Queue created: ${queue.name}`);
94
- // return queue.name!;
95
- // }
96
- // public async ensureServiceAccount() {
97
- // const auth = await google.auth.getClient({
98
- // scopes: ["https://www.googleapis.com/auth/cloud-platform"],
99
- // });
100
- // const iam = google.iam({ version: "v1", auth });
101
- // const saEmail = `${this.config.serviceAccount}@${this.config.projectId}.iam.gserviceaccount.com`;
102
- // const saName = `projects/${this.config.projectId}/serviceAccounts/${saEmail}`;
103
- // try {
104
- // const existing = await iam.projects.serviceAccounts.get({ name: saName });
105
- // console.log(`Service account exists: ${existing.data.email}`);
106
- // return { saEmail, saName };
107
- // } catch {
108
- // // continue to create
109
- // }
110
- // const created = await iam.projects.serviceAccounts.create({
111
- // name: `projects/${this.config.projectId}`,
112
- // requestBody: {
113
- // accountId: this.config.serviceAccount,
114
- // },
115
- // });
116
- // console.log(`Service account created: ${created.data.email}`);
117
- // return { saEmail, saName };
118
- // }
119
- // /**
120
- // * Cloud Functions gen2 uses Cloud Run under the hood.
121
- // * The clean way is to grant roles/run.invoker on the underlying Cloud Run service.
122
- // *
123
- // * Problem: mapping from your exec URL to Cloud Run service name programmatically is non-trivial
124
- // * without calling the Cloud Functions API to resolve it. So:
125
- // * - We offer a best-effort attempt using Cloud Functions v2 API to look up the function,
126
- // * if you provide FUNCTION_NAME (e.g. picpadMedicationService).
127
- // * - Otherwise, we print manual steps.
128
- // */
129
- // public async tryGrantInvokerBinding(saEmail: string) {
130
- // // function name
131
- // const functionName = process.env.FUNCTION_NAME; // e.g. picpadMedicationService
132
- // if (!functionName) {
133
- // console.log(
134
- // `Skipping IAM binding: set FUNCTION_NAME=picpadMedicationService (or your function name) to enable lookup.`,
135
- // );
136
- // console.log(
137
- // `Manual action needed: grant roles/run.invoker to ${saEmail} on the exec endpoint.`,
138
- // );
139
- // return;
140
- // }
141
- // const auth = await google.auth.getClient({
142
- // scopes: ["https://www.googleapis.com/auth/cloud-platform"],
143
- // });
144
- // // 1) Resolve function -> underlying Cloud Run service
145
- // const cloudfunctions = google.cloudfunctions({ version: "v2", auth });
146
- // const fnFullName = `projects/${this.config.projectId}/locations/${this.config.region}/functions/${functionName}`;
147
- // const fn = await cloudfunctions.projects.locations.functions.get({
148
- // name: fnFullName,
149
- // });
150
- // const serviceUri = fn.data?.serviceConfig?.uri;
151
- // if (!serviceUri) {
152
- // console.log(
153
- // `Could not resolve Cloud Run URI for function ${fnFullName}.`,
154
- // );
155
- // console.log(
156
- // `Manual action needed: grant roles/run.invoker to ${saEmail}.`,
157
- // );
158
- // return;
159
- // }
160
- // // Cloud Run service name is not directly the URI, but we can still tell the user exactly what URI it is.
161
- // console.log(`Function resolved. Cloud Run URI: ${serviceUri}`);
162
- // console.log(
163
- // `NOTE: Automatically applying IAM to Cloud Run via URI alone isn't supported here; do it via gcloud or console.`,
164
- // );
165
- // // We can still verify the URI matches what you think you're calling.
166
- // console.log(`Your EXEC_ENDPOINT_URL: ${this.config.functionUrl}`);
167
- // console.log(`Resolved serviceConfig.uri: ${serviceUri}`);
168
- // console.log(
169
- // `If these differ, Cloud Tasks can still call EXEC_ENDPOINT_URL, but IAM must allow the OIDC SA.`,
170
- // );
171
- // }
172
- // }
173
- //# sourceMappingURL=TaskSetup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskSetup.js","sourceRoot":"","sources":["../../src/tasks/TaskSetup.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,0DAA0D;AAC1D,WAAW;AACX,kBAAkB;AAClB,gBAAgB;AAChB,gBAAgB;AAChB,sCAAsC;AACtC,uCAAuC;;AAEvC,2BAA2B;AAC3B,kCAAkC;AAElC,wBAAwB;AACxB,6CAA6C;AAC7C,4CAA4C;AAC5C,QAAQ;AACR,qDAAqD;AACrD,MAAM;AAEN,yBAAyB;AACzB,4CAA4C;AAE5C,uDAAuD;AACvD,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A8B;AAC9B,QAAQ;AAER,kEAAkE;AAClE,mDAAmD;AACnD,uBAAuB;AACvB,iDAAiD;AACjD,WAAW;AACX,UAAU;AAEV,qEAAqE;AACrE,kCAAkC;AAClC,MAAM;AAEN,QAAQ;AACR,2DAA2D;AAC3D,wFAAwF;AACxF,OAAO;AACP,qGAAqG;AACrG,kEAAkE;AAClE,8FAA8F;AAC9F,sEAAsE;AACtE,2CAA2C;AAC3C,QAAQ;AACR,2DAA2D;AAC3D,wBAAwB;AACxB,sFAAsF;AACtF,2BAA2B;AAC3B,qBAAqB;AACrB,uHAAuH;AACvH,WAAW;AACX,qBAAqB;AACrB,+FAA+F;AAC/F,WAAW;AACX,gBAAgB;AAChB,QAAQ;AAER,iDAAiD;AACjD,oEAAoE;AACpE,UAAU;AAEV,6DAA6D;AAC7D,6EAA6E;AAE7E,wHAAwH;AACxH,yEAAyE;AACzE,0BAA0B;AAC1B,UAAU;AAEV,sDAAsD;AACtD,yBAAyB;AACzB,qBAAqB;AACrB,yEAAyE;AACzE,WAAW;AACX,qBAAqB;AACrB,0EAA0E;AAC1E,WAAW;AACX,gBAAgB;AAChB,QAAQ;AAER,gHAAgH;AAChH,sEAAsE;AACtE,mBAAmB;AACnB,0HAA0H;AAC1H,SAAS;AAET,4EAA4E;AAC5E,yEAAyE;AACzE,gEAAgE;AAChE,mBAAmB;AACnB,0GAA0G;AAC1G,SAAS;AACT,MAAM;AACN,IAAI"}
@@ -1,3 +0,0 @@
1
- export * from "./TaskHandler.js";
2
- export * from "./TaskSetup.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -1,4 +0,0 @@
1
- // This file is auto-generated by build-cli. Do not edit manually.
2
- export * from "./TaskHandler.js";
3
- export * from "./TaskSetup.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}