@spica/cli 0.9.20 → 0.9.24

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 (43) hide show
  1. package/index.js +1 -1
  2. package/package.json +3 -2
  3. package/src/commands/function/orm.d.ts +2 -0
  4. package/src/commands/function/orm.js +73 -0
  5. package/src/commands/function/orm.js.map +1 -0
  6. package/src/commands/project/start.js +3 -2
  7. package/src/commands/project/start.js.map +1 -1
  8. package/src/commands/project/sync.d.ts +44 -3
  9. package/src/commands/project/sync.js +261 -63
  10. package/src/commands/project/sync.js.map +1 -1
  11. package/src/compile.d.ts +22 -0
  12. package/src/compile.js +116 -0
  13. package/src/compile.js.map +1 -0
  14. package/src/function/helpers.d.ts +2 -0
  15. package/src/function/helpers.js +16 -0
  16. package/src/function/helpers.js.map +1 -0
  17. package/src/function/index.d.ts +2 -0
  18. package/src/function/index.js +9 -0
  19. package/src/function/index.js.map +1 -0
  20. package/src/function/interface.d.ts +28 -0
  21. package/src/function/interface.js +7 -0
  22. package/src/function/interface.js.map +1 -0
  23. package/src/function/modifier.d.ts +41 -0
  24. package/src/function/modifier.js +69 -0
  25. package/src/function/modifier.js.map +1 -0
  26. package/src/function/triggers/http/index.d.ts +7 -0
  27. package/src/function/triggers/http/index.js +12 -0
  28. package/src/function/triggers/http/index.js.map +1 -0
  29. package/src/function/triggers/http/services/axios.d.ts +46 -0
  30. package/src/function/triggers/http/services/axios.js +169 -0
  31. package/src/function/triggers/http/services/axios.js.map +1 -0
  32. package/src/function/triggers/http/services/index.d.ts +3 -0
  33. package/src/function/triggers/http/services/index.js +10 -0
  34. package/src/function/triggers/http/services/index.js.map +1 -0
  35. package/src/function/triggers/http/transformer.d.ts +16 -0
  36. package/src/function/triggers/http/transformer.js +53 -0
  37. package/src/function/triggers/http/transformer.js.map +1 -0
  38. package/src/function/triggers/index.d.ts +4 -0
  39. package/src/function/triggers/index.js +10 -0
  40. package/src/function/triggers/index.js.map +1 -0
  41. package/src/validator.d.ts +2 -0
  42. package/src/validator.js +7 -2
  43. package/src/validator.js.map +1 -1
package/src/compile.js ADDED
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunctionCompiler = void 0;
4
+ const ts = require("typescript");
5
+ const helpers_1 = require("./function/helpers");
6
+ const triggers_1 = require("./function/triggers");
7
+ class FunctionCompiler {
8
+ constructor(fn, triggerTypes, baseUrl, triggerOptions, transformers = triggers_1.triggerTransformers) {
9
+ this.fn = fn;
10
+ this.triggerTypes = triggerTypes;
11
+ this.baseUrl = baseUrl;
12
+ this.triggerOptions = triggerOptions;
13
+ this.transformers = transformers;
14
+ this.fn.triggers = this.filterTriggers(this.fn.triggers, ([_, trigger]) => this.triggerTypes.includes(trigger.type));
15
+ this.sourceFile = ts.createSourceFile(fn.name, fn.index, ts.ScriptTarget.Latest);
16
+ }
17
+ compile() {
18
+ const transformers = [];
19
+ const imports = [];
20
+ const extraFunctions = [];
21
+ const addImports = (_imports) => imports.push(..._imports);
22
+ const addExtraFunctions = (fns) => extraFunctions.push(...fns);
23
+ const handlerNames = this.getHandlerNames();
24
+ const handlerFilterer = this.getHandlerFiltererTransformer(handlerNames);
25
+ transformers.push(handlerFilterer);
26
+ for (const triggerType of this.triggerTypes) {
27
+ const factory = this.transformers.get(triggerType);
28
+ if (!factory) {
29
+ throw Error(`Trigger type ${triggerType} does not have any transformer.`);
30
+ }
31
+ const relevantTriggers = this.filterTriggers(this.fn.triggers, ([_, trigger]) => trigger.type == triggerType);
32
+ if (!Object.keys(relevantTriggers).length) {
33
+ continue;
34
+ }
35
+ const transformerOptions = {
36
+ ...this.triggerOptions[triggerType],
37
+ addImports,
38
+ addExtraFunctions
39
+ };
40
+ const transformer = factory(relevantTriggers, this.baseUrl, transformerOptions);
41
+ transformers.push(transformer.getTransformer());
42
+ }
43
+ this.sourceFile = ts.transform(this.sourceFile, transformers).transformed[0];
44
+ this.sourceFile = ts.factory.updateSourceFile(this.sourceFile, [
45
+ ...imports,
46
+ ...this.sourceFile.statements,
47
+ ...extraFunctions
48
+ ]);
49
+ const code = ts.createPrinter().printFile(this.sourceFile);
50
+ switch (this.fn.language) {
51
+ case "typescript":
52
+ return [{ extension: "ts", content: code }];
53
+ case "javascript":
54
+ const types = this.generateTypesOfCode(code);
55
+ return [{ extension: "js", content: code }, { extension: "d.ts", content: types }];
56
+ default:
57
+ throw Error(`Language named ${this.fn.language} has no compiler yet.`);
58
+ }
59
+ }
60
+ getHandlerNames() {
61
+ return Object.keys(this.fn.triggers);
62
+ }
63
+ filterTriggers(triggers, filter) {
64
+ return Object.entries(triggers)
65
+ .filter(filter)
66
+ .reduce((acc, [handler, trigger]) => {
67
+ acc[handler] = trigger;
68
+ return acc;
69
+ }, {});
70
+ }
71
+ getHandlerFiltererTransformer(handlerNames) {
72
+ const transformer = context => rootNode => {
73
+ const visitor = (node) => {
74
+ const isRootNode = node.kind == ts.SyntaxKind.SourceFile;
75
+ if (isRootNode) {
76
+ return ts.visitEachChild(node, visitor, context);
77
+ }
78
+ const isNecessaryStatement = ts.isFunctionDeclaration(node)
79
+ ? handlerNames.includes((0, helpers_1.getFunctionName)(node))
80
+ : false;
81
+ if (!isNecessaryStatement) {
82
+ return this.disableStatement(node);
83
+ }
84
+ return node;
85
+ };
86
+ return ts.visitNode(rootNode, visitor);
87
+ };
88
+ return transformer;
89
+ }
90
+ codeToAst(code) {
91
+ return ts.createSourceFile("name.ts", code, ts.ScriptTarget.Latest);
92
+ }
93
+ disableStatement(node) {
94
+ node = ts.factory.createEmptyStatement();
95
+ node = ts.addSyntheticLeadingComment(node, ts.SyntaxKind.SingleLineCommentTrivia, " This statement has been deleted.");
96
+ return node;
97
+ }
98
+ generateTypesOfCode(code) {
99
+ let types;
100
+ const options = {
101
+ allowJs: true,
102
+ declaration: true,
103
+ emitDeclarationOnly: true
104
+ };
105
+ const host = ts.createCompilerHost(options);
106
+ host.writeFile = (_, data) => {
107
+ types = data;
108
+ };
109
+ host.readFile = () => code;
110
+ const program = ts.createProgram(["dummy.js"], options, host);
111
+ program.emit();
112
+ return types;
113
+ }
114
+ }
115
+ exports.FunctionCompiler = FunctionCompiler;
116
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../../../../stacks/cli/src/compile.ts"],"names":[],"mappings":";;;AACA,iCAAiC;AACjC,gDAAmD;AAEnD,kDAAwD;AAExD,MAAa,gBAAgB;IAG3B,YACU,EAAqB,EACrB,YAAsB,EACtB,OAAe,EACf,cAA8B,EAC9B,eAAe,8BAAmB;QAJlC,OAAE,GAAF,EAAE,CAAmB;QACrB,iBAAY,GAAZ,YAAY,CAAU;QACtB,YAAO,GAAP,OAAO,CAAQ;QACf,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAsB;QAE1C,IAAI,CAAC,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CACxE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CACzC,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,OAAO;QACL,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,MAAM,cAAc,GAA6B,EAAE,CAAC;QAEpD,MAAM,UAAU,GAAG,CAAC,QAAgC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QACnF,MAAM,iBAAiB,GAAG,CAAC,GAA6B,EAAE,EAAE,CAAC,c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AAkB,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;YAC3B,KAAK,GAAG,IAAI,CAAC;QACf,CAAC,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;QAE3B,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,EAAE,CAAC;QAEf,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAhKD,4CAgKC"}
@@ -0,0 +1,2 @@
1
+ import * as ts from "typescript";
2
+ export declare function getFunctionName(node: ts.FunctionDeclaration): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFunctionName = void 0;
4
+ const ts = require("typescript");
5
+ function getFunctionName(node) {
6
+ if (node.name) {
7
+ return node.name.escapedText;
8
+ }
9
+ const isDefault = node.modifiers.findIndex(m => m.kind == ts.SyntaxKind.DefaultKeyword) != -1;
10
+ if (isDefault) {
11
+ return "default";
12
+ }
13
+ return undefined;
14
+ }
15
+ exports.getFunctionName = getFunctionName;
16
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../../stacks/cli/src/function/helpers.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,SAAgB,eAAe,CAAC,IAA4B;IAC1D,IAAI,IAAI,CAAC,IAAI,EAAE;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAqB,CAAC;KACxC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9F,IAAI,SAAS,EAAE;QACb,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,0CAWC"}
@@ -0,0 +1,2 @@
1
+ export { FunctionDeclarationModifier, SpicaFunctionModifier } from "./modifier";
2
+ export { getFunctionName } from "./helpers";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFunctionName = exports.SpicaFunctionModifier = exports.FunctionDeclarationModifier = void 0;
4
+ var modifier_1 = require("./modifier");
5
+ Object.defineProperty(exports, "FunctionDeclarationModifier", { enumerable: true, get: function () { return modifier_1.FunctionDeclarationModifier; } });
6
+ Object.defineProperty(exports, "SpicaFunctionModifier", { enumerable: true, get: function () { return modifier_1.SpicaFunctionModifier; } });
7
+ var helpers_1 = require("./helpers");
8
+ Object.defineProperty(exports, "getFunctionName", { enumerable: true, get: function () { return helpers_1.getFunctionName; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../stacks/cli/src/function/index.ts"],"names":[],"mappings":";;;AAAA,uCAA8E;AAAtE,uHAAA,2BAA2B,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAC1D,qCAA0C;AAAlC,0GAAA,eAAe,OAAA"}
@@ -0,0 +1,28 @@
1
+ import { Triggers, Function, Trigger } from "@spica-server/interface/function";
2
+ import * as ts from "typescript";
3
+ import { FunctionDeclarationModifier } from "./modifier";
4
+ export declare abstract class TriggerTransformer<T extends ts.Node> {
5
+ static _name: string;
6
+ abstract getTransformer: () => ts.TransformerFactory<T>;
7
+ abstract getVisitor: (triggers: Triggers, context: ts.TransformationContext) => ts.Visitor;
8
+ }
9
+ export declare type FunctionWithIndex = Function & {
10
+ index: string;
11
+ };
12
+ export declare type FunctionModifier = (node: ts.FunctionDeclaration, handler: string, baseUrl: string, trigger: Trigger) => FunctionDeclarationModifier;
13
+ export declare type FunctionModifiers = Map<string, FunctionModifier>;
14
+ export declare type TriggerTransformers<T extends ts.Node> = Map<string, (triggers: Triggers, baseUrl: string, options: TriggerTransformerOptions) => TriggerTransformer<T>>;
15
+ export interface TriggerOptions {
16
+ http?: HttpOptions;
17
+ }
18
+ export interface HttpOptions {
19
+ selectedService: string;
20
+ }
21
+ export interface CommonTriggerTransformerOptions {
22
+ addImports: (imports: ts.ImportDeclaration[]) => void;
23
+ addExtraFunctions: (fns: ts.FunctionDeclaration[]) => void;
24
+ }
25
+ export declare type TriggerTransformerOptions = {
26
+ [key: string]: any;
27
+ } & CommonTriggerTransformerOptions;
28
+ export declare type HttpTriggerTransformerOptions = HttpOptions & CommonTriggerTransformerOptions;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriggerTransformer = void 0;
4
+ class TriggerTransformer {
5
+ }
6
+ exports.TriggerTransformer = TriggerTransformer;
7
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../../../stacks/cli/src/function/interface.ts"],"names":[],"mappings":";;;AAIA,MAAsB,kBAAkB;CAIvC;AAJD,gDAIC"}
@@ -0,0 +1,41 @@
1
+ import * as ts from "typescript";
2
+ export declare abstract class FunctionDeclarationModifier {
3
+ private node;
4
+ static modifierName: string;
5
+ modifiers: ts.Modifier[];
6
+ name: ts.Identifier;
7
+ asteriksToken: ts.AsteriskToken;
8
+ typeParameters: ts.TypeParameterDeclaration[];
9
+ type: ts.TypeNode;
10
+ body: ts.FunctionBody;
11
+ parameters: ts.ParameterDeclaration[];
12
+ decorators: ts.Decorator[];
13
+ constructor(node: ts.FunctionDeclaration);
14
+ abstract setBody(): ts.FunctionBody;
15
+ abstract setParameters(): ts.ParameterDeclaration[];
16
+ abstract setDecorators(): ts.Decorator[];
17
+ abstract setAsteriksToken(): ts.AsteriskToken;
18
+ abstract setTypeParameters(): ts.TypeParameterDeclaration[];
19
+ abstract setType(): ts.TypeNode;
20
+ abstract setModifiers(): ts.Modifier[];
21
+ abstract setName(): ts.Identifier;
22
+ abstract getExtraFunctionDeclarations(): ts.FunctionDeclaration[];
23
+ private setAllDeclarationDependencies;
24
+ abstract getImports(): ts.ImportDeclaration[];
25
+ modify(): ts.FunctionDeclaration;
26
+ }
27
+ export declare class SpicaFunctionModifier extends FunctionDeclarationModifier {
28
+ handler: string;
29
+ setBody(): any;
30
+ setParameters(): any[];
31
+ setDecorators(): any;
32
+ setAsteriksToken(): any;
33
+ setTypeParameters(): any;
34
+ setType(): any;
35
+ constructor(node: ts.FunctionDeclaration, handler: string);
36
+ private get isHandlerDefault();
37
+ setModifiers(): ts.Modifier[];
38
+ setName(): ts.Identifier;
39
+ getImports(): ts.ImportDeclaration[];
40
+ getExtraFunctionDeclarations(): ts.FunctionDeclaration[];
41
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpicaFunctionModifier = exports.FunctionDeclarationModifier = void 0;
4
+ const ts = require("typescript");
5
+ class FunctionDeclarationModifier {
6
+ constructor(node) {
7
+ this.node = node;
8
+ }
9
+ setAllDeclarationDependencies() {
10
+ this.modifiers = this.setModifiers();
11
+ this.name = this.setName();
12
+ this.body = this.setBody();
13
+ this.parameters = this.setParameters();
14
+ this.decorators = this.setDecorators();
15
+ this.asteriksToken = this.setAsteriksToken();
16
+ this.typeParameters = this.setTypeParameters();
17
+ this.type = this.setType();
18
+ }
19
+ modify() {
20
+ this.setAllDeclarationDependencies();
21
+ return ts.factory.updateFunctionDeclaration(this.node, this.decorators, this.modifiers, this.asteriksToken, this.name, this.typeParameters, this.parameters, this.type, this.body);
22
+ }
23
+ }
24
+ exports.FunctionDeclarationModifier = FunctionDeclarationModifier;
25
+ class SpicaFunctionModifier extends FunctionDeclarationModifier {
26
+ constructor(node, handler) {
27
+ super(node);
28
+ this.handler = handler;
29
+ }
30
+ setBody() {
31
+ return undefined;
32
+ }
33
+ setParameters() {
34
+ return [];
35
+ }
36
+ setDecorators() {
37
+ return undefined;
38
+ }
39
+ setAsteriksToken() {
40
+ return undefined;
41
+ }
42
+ setTypeParameters() {
43
+ return undefined;
44
+ }
45
+ setType() {
46
+ return undefined;
47
+ }
48
+ get isHandlerDefault() {
49
+ return this.handler == "default";
50
+ }
51
+ setModifiers() {
52
+ const modifiers = [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)];
53
+ if (this.isHandlerDefault) {
54
+ modifiers.push(ts.factory.createModifier(ts.SyntaxKind.DefaultKeyword));
55
+ }
56
+ return modifiers;
57
+ }
58
+ setName() {
59
+ return !this.isHandlerDefault ? ts.factory.createIdentifier(this.handler) : undefined;
60
+ }
61
+ getImports() {
62
+ return [];
63
+ }
64
+ getExtraFunctionDeclarations() {
65
+ return [];
66
+ }
67
+ }
68
+ exports.SpicaFunctionModifier = SpicaFunctionModifier;
69
+ //# sourceMappingURL=modifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifier.js","sourceRoot":"","sources":["../../../../../../../stacks/cli/src/function/modifier.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,MAAsB,2BAA2B;IAa/C,YAAoB,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;IAAG,CAAC;IAoB5C,6BAA6B;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAGvC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,IAAI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CAAC,CAAC,CAAC;SACzE;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IAED,UAAU;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,4BAA4B;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAxDD,sDAwDC"}
@@ -0,0 +1,7 @@
1
+ import { HttpTriggerTransformerOptions } from "../../interface";
2
+ import { HttpTransformer } from "./transformer";
3
+ export { HttpTransformer } from "./transformer";
4
+ export declare const http: {
5
+ name: string;
6
+ factory: (triggers: any, baseUrl: any, options: HttpTriggerTransformerOptions) => HttpTransformer;
7
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.http = exports.HttpTransformer = void 0;
4
+ const services_1 = require("./services");
5
+ const transformer_1 = require("./transformer");
6
+ var transformer_2 = require("./transformer");
7
+ Object.defineProperty(exports, "HttpTransformer", { enumerable: true, get: function () { return transformer_2.HttpTransformer; } });
8
+ exports.http = {
9
+ name: transformer_1.HttpTransformer._name,
10
+ factory: (triggers, baseUrl, options) => new transformer_1.HttpTransformer(triggers, baseUrl, options, services_1.httpServiceModifiers)
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../stacks/cli/src/function/triggers/http/index.ts"],"names":[],"mappings":";;;AACA,yCAAgD;AAChD,+CAA8C;AAC9C,6CAA8C;AAAtC,8GAAA,eAAe,OAAA;AAEV,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,6BAAe,CAAC,KAAK;IAC3B,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAsC,EAAE,EAAE,CACrE,IAAI,6BAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,+BAAoB,CAAC;CACxE,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Trigger } from "@spica-server/interface/function";
2
+ import * as ts from "typescript";
3
+ import { FunctionDeclarationModifier, SpicaFunctionModifier } from "../../../modifier";
4
+ export declare class Axios extends SpicaFunctionModifier {
5
+ private validators;
6
+ static modifierName: string;
7
+ url: string;
8
+ method: string;
9
+ extraFunctionDeclarations: ts.FunctionDeclaration[];
10
+ registeredValidators: FunctionDeclarationModifier[];
11
+ constructor(node: ts.FunctionDeclaration, handler: string, baseUrl: string, trigger: Trigger, validators?: ((node: any) => AxiosWriteValidator)[]);
12
+ getExtraFunctionDeclarations(): ts.FunctionDeclaration[];
13
+ getImports(): ts.ImportDeclaration[];
14
+ setParameters(): ts.ParameterDeclaration[];
15
+ setBody(): ts.Block;
16
+ }
17
+ export declare class AxiosWriteValidator extends FunctionDeclarationModifier {
18
+ static modifierName: string;
19
+ setAsteriksToken(): ts.AsteriskToken;
20
+ setTypeParameters(): ts.TypeParameterDeclaration[];
21
+ setModifiers(): any[];
22
+ setType(): ts.TypeNode;
23
+ setDecorators(): any[];
24
+ getImports(): any[];
25
+ getExtraFunctionDeclarations(): ts.FunctionDeclaration[];
26
+ setName(): ts.Identifier;
27
+ setParameters(): ts.ParameterDeclaration[];
28
+ setBody(): ts.Block;
29
+ }
30
+ export declare class AxiosReadValidator extends FunctionDeclarationModifier {
31
+ static modifierName: string;
32
+ setAsteriksToken(): ts.AsteriskToken;
33
+ setTypeParameters(): ts.TypeParameterDeclaration[];
34
+ setModifiers(): any[];
35
+ setType(): ts.TypeNode;
36
+ setDecorators(): any[];
37
+ getImports(): any[];
38
+ getExtraFunctionDeclarations(): ts.FunctionDeclaration[];
39
+ setName(): ts.Identifier;
40
+ setParameters(): ts.ParameterDeclaration[];
41
+ setBody(): ts.Block;
42
+ }
43
+ export declare const axios: {
44
+ name: string;
45
+ factory: (node: any, handler: any, baseUrl: any, trigger: any) => Axios;
46
+ };
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.axios = exports.AxiosReadValidator = exports.AxiosWriteValidator = exports.Axios = void 0;
4
+ const ts = require("typescript");
5
+ const modifier_1 = require("../../../modifier");
6
+ class Axios extends modifier_1.SpicaFunctionModifier {
7
+ constructor(node, handler, baseUrl, trigger, validators = axiosValidators) {
8
+ super(node, handler);
9
+ this.validators = validators;
10
+ this.extraFunctionDeclarations = [];
11
+ this.registeredValidators = [];
12
+ this.url = `${baseUrl}/fn-execute${trigger.options.path}`;
13
+ this.method = trigger.options.method;
14
+ for (const factory of this.validators) {
15
+ const emptyFn = ts.factory.createFunctionDeclaration([], [], undefined, undefined, [], [], undefined, undefined);
16
+ const validator = factory(emptyFn);
17
+ this.registeredValidators.push(validator);
18
+ this.extraFunctionDeclarations.push(validator.modify());
19
+ }
20
+ }
21
+ getExtraFunctionDeclarations() {
22
+ return this.extraFunctionDeclarations;
23
+ }
24
+ getImports() {
25
+ const importClause = ts.factory.createImportClause(false, ts.factory.createIdentifier("axios"), undefined);
26
+ const importDeclaration = ts.factory.createImportDeclaration(undefined, undefined, importClause, ts.factory.createStringLiteral("axios"));
27
+ return [importDeclaration];
28
+ }
29
+ setParameters() {
30
+ return [
31
+ ts.factory.createParameterDeclaration(undefined, undefined, undefined, ts.factory.createIdentifier("config"), undefined, undefined, undefined)
32
+ ];
33
+ }
34
+ setBody() {
35
+ const configValue = ts.factory.createObjectLiteralExpression([
36
+ ts.factory.createSpreadAssignment(ts.factory.createIdentifier("config")),
37
+ ts.factory.createPropertyAssignment(ts.factory.createIdentifier("method"), ts.factory.createStringLiteral(this.method.toLowerCase())),
38
+ ts.factory.createPropertyAssignment(ts.factory.createIdentifier("url"), ts.factory.createStringLiteral(this.url))
39
+ ]);
40
+ const configAssigment = ts.factory.createBinaryExpression(ts.factory.createIdentifier("config"), ts.SyntaxKind.FirstAssignment, configValue);
41
+ const configStatement = ts.factory.createExpressionStatement(configAssigment);
42
+ const validatorCalls = [];
43
+ for (const validator of this.registeredValidators) {
44
+ const call = ts.factory.createCallExpression(validator.name, undefined, [
45
+ ts.factory.createIdentifier("config")
46
+ ]);
47
+ validatorCalls.push(ts.factory.createExpressionStatement(call));
48
+ }
49
+ const requestAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("axios"), ts.factory.createIdentifier("request"));
50
+ const requestArgs = [ts.factory.createIdentifier("config")];
51
+ const requestCall = ts.factory.createCallExpression(requestAccess, undefined, requestArgs);
52
+ const thenParams = [
53
+ ts.factory.createParameterDeclaration(undefined, undefined, undefined, ts.factory.createIdentifier("r"), undefined, undefined, undefined)
54
+ ];
55
+ const thenBody = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("r"), ts.factory.createIdentifier("data"));
56
+ const thenArgs = ts.factory.createArrowFunction(undefined, undefined, thenParams, undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), thenBody);
57
+ const thenAccess = ts.factory.createPropertyAccessExpression(requestCall, ts.factory.createIdentifier("then"));
58
+ const thenCall = ts.factory.createCallExpression(thenAccess, undefined, [thenArgs]);
59
+ const returnStatement = ts.factory.createReturnStatement(thenCall);
60
+ return ts.factory.createBlock([configStatement, ...validatorCalls, returnStatement], true);
61
+ }
62
+ }
63
+ exports.Axios = Axios;
64
+ Axios.modifierName = "axios";
65
+ class AxiosWriteValidator extends modifier_1.FunctionDeclarationModifier {
66
+ setAsteriksToken() {
67
+ return undefined;
68
+ }
69
+ setTypeParameters() {
70
+ return [];
71
+ }
72
+ setModifiers() {
73
+ return [];
74
+ }
75
+ setType() {
76
+ return undefined;
77
+ }
78
+ setDecorators() {
79
+ return [];
80
+ }
81
+ getImports() {
82
+ return [];
83
+ }
84
+ getExtraFunctionDeclarations() {
85
+ return [];
86
+ }
87
+ setName() {
88
+ return ts.factory.createIdentifier(AxiosWriteValidator.modifierName);
89
+ }
90
+ setParameters() {
91
+ return [
92
+ ts.factory.createParameterDeclaration(undefined, undefined, undefined, ts.factory.createIdentifier("config"))
93
+ ];
94
+ }
95
+ setBody() {
96
+ const writeMethods = ["post", "put", "patch"];
97
+ const writeMethodsArray = ts.factory.createArrayLiteralExpression(writeMethods.map(m => ts.factory.createStringLiteral(m)), false);
98
+ const includes = ts.factory.createPropertyAccessExpression(writeMethodsArray, ts.factory.createIdentifier("includes"));
99
+ const configMethodAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("config"), ts.factory.createIdentifier("method"));
100
+ const includesCall = ts.factory.createCallExpression(includes, undefined, [configMethodAccess]);
101
+ const configData = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("config"), ts.factory.createIdentifier("data"));
102
+ const binaryExpression = ts.factory.createLogicalAnd(includesCall, ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.ExclamationToken, configData));
103
+ const warningMessage = `Sending empty request body for ${writeMethods.join(", ")} requests is unusual. If it's not intented, please use config.data or update your spica function.`;
104
+ const consoleWarnAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("console"), ts.factory.createIdentifier("warn"));
105
+ const consoleWarnCall = ts.factory.createCallExpression(consoleWarnAccess, [], [ts.factory.createStringLiteral(warningMessage)]);
106
+ const ifStatementBody = ts.factory.createBlock([ts.factory.createExpressionStatement(consoleWarnCall)], true);
107
+ const IfStatement = ts.factory.createIfStatement(binaryExpression, ifStatementBody);
108
+ return ts.factory.createBlock([IfStatement], true);
109
+ }
110
+ }
111
+ exports.AxiosWriteValidator = AxiosWriteValidator;
112
+ AxiosWriteValidator.modifierName = "axiosWriteValidator";
113
+ class AxiosReadValidator extends modifier_1.FunctionDeclarationModifier {
114
+ setAsteriksToken() {
115
+ return undefined;
116
+ }
117
+ setTypeParameters() {
118
+ return [];
119
+ }
120
+ setModifiers() {
121
+ return [];
122
+ }
123
+ setType() {
124
+ return undefined;
125
+ }
126
+ setDecorators() {
127
+ return [];
128
+ }
129
+ getImports() {
130
+ return [];
131
+ }
132
+ getExtraFunctionDeclarations() {
133
+ return [];
134
+ }
135
+ setName() {
136
+ return ts.factory.createIdentifier(AxiosReadValidator.modifierName);
137
+ }
138
+ setParameters() {
139
+ return [
140
+ ts.factory.createParameterDeclaration(undefined, undefined, undefined, ts.factory.createIdentifier("config"))
141
+ ];
142
+ }
143
+ setBody() {
144
+ const readMethods = ["get", "delete", "trace", "options", "head"];
145
+ const readMethodsArray = ts.factory.createArrayLiteralExpression(readMethods.map(m => ts.factory.createStringLiteral(m)), false);
146
+ const includes = ts.factory.createPropertyAccessExpression(readMethodsArray, ts.factory.createIdentifier("includes"));
147
+ const configMethodAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("config"), ts.factory.createIdentifier("method"));
148
+ const includesCall = ts.factory.createCallExpression(includes, undefined, [configMethodAccess]);
149
+ const configData = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("config"), ts.factory.createIdentifier("data"));
150
+ const binaryExpression = ts.factory.createLogicalAnd(includesCall, configData);
151
+ const warningMessage = `Sending request body for ${readMethods.join(", ")} requests is unusual. If it's not intented, please remove config.data or update your spica function.`;
152
+ const consoleWarnAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("console"), ts.factory.createIdentifier("warn"));
153
+ const consoleWarnCall = ts.factory.createCallExpression(consoleWarnAccess, [], [ts.factory.createStringLiteral(warningMessage)]);
154
+ const ifStatementBody = ts.factory.createBlock([ts.factory.createExpressionStatement(consoleWarnCall)], true);
155
+ const IfStatement = ts.factory.createIfStatement(binaryExpression, ifStatementBody);
156
+ return ts.factory.createBlock([IfStatement], true);
157
+ }
158
+ }
159
+ exports.AxiosReadValidator = AxiosReadValidator;
160
+ AxiosReadValidator.modifierName = "axiosReadValidator";
161
+ const axiosValidators = [
162
+ node => new AxiosWriteValidator(node),
163
+ node => new AxiosReadValidator(node)
164
+ ];
165
+ exports.axios = {
166
+ name: Axios.modifierName,
167
+ factory: (node, handler, baseUrl, trigger) => new Axios(node, handler, baseUrl, trigger)
168
+ };
169
+ //# sourceMappingURL=axios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../../../../../../../../stacks/cli/src/function/triggers/http/services/axios.ts"],"names":[],"mappings":";;;AACA,iCAAiC;AACjC,gDAAqF;AAErF,MAAa,KAAM,SAAQ,gCAAqB;IAS9C,YACE,IAA4B,EAC5B,OAAe,EACf,OAAe,EACf,OAAgB,EACR,aAAa,eAAe;QAEpC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAFb,eAAU,GAAV,UAAU,CAAkB;QARtC,8BAAyB,GAA6B,EAAE,CAAC;QACzD,yBAAoB,GAAkC,EAAE,CAAC;QAWvD,IAAI,CAAC,GAAG,GAAG,GAAG,OAAO,cAAc,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;QAErC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;YACrC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAClD,EAAE,EACF,EAAE,EACF,SAAS,EACT,SAAS,EACT,EAAE,EACF,EAAE,EACF,SAAS,EACT,SAAS,CACV,CAAC;YACF,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAA4B,CAAC,CAAC;SACnF;IACH,CAAC;IAED,4BAA4B;QAC1B,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC;IAED,UAAU;QACR,MAAM,YAAY,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAChD,KAAK,EACL,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,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{ FunctionModifiers } from "@spica/cli/src/function/interface";
2
+ export { Axios, AxiosReadValidator, AxiosWriteValidator } from "./axios";
3
+ export declare const httpServiceModifiers: FunctionModifiers;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpServiceModifiers = exports.AxiosWriteValidator = exports.AxiosReadValidator = exports.Axios = void 0;
4
+ const axios_1 = require("./axios");
5
+ var axios_2 = require("./axios");
6
+ Object.defineProperty(exports, "Axios", { enumerable: true, get: function () { return axios_2.Axios; } });
7
+ Object.defineProperty(exports, "AxiosReadValidator", { enumerable: true, get: function () { return axios_2.AxiosReadValidator; } });
8
+ Object.defineProperty(exports, "AxiosWriteValidator", { enumerable: true, get: function () { return axios_2.AxiosWriteValidator; } });
9
+ exports.httpServiceModifiers = new Map([[axios_1.axios.name, axios_1.axios.factory]]);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../../stacks/cli/src/function/triggers/http/services/index.ts"],"names":[],"mappings":";;;AACA,mCAA8B;AAC9B,iCAAuE;AAA/D,8FAAA,KAAK,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAEzC,QAAA,oBAAoB,GAAsB,IAAI,GAAG,CAAC,CAAC,CAAC,aAAK,CAAC,IAAI,EAAE,aAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Triggers } from "@spica-server/interface/function";
2
+ import * as ts from "typescript";
3
+ import { TriggerTransformer, FunctionModifier, HttpTriggerTransformerOptions, FunctionModifiers } from "../../interface";
4
+ export declare class HttpTransformer implements TriggerTransformer<ts.Node> {
5
+ private triggers;
6
+ private baseUrl;
7
+ private options;
8
+ private modifiers;
9
+ static _name: string;
10
+ modifier: FunctionModifier;
11
+ importsAdded: boolean;
12
+ extraFnsAdded: boolean;
13
+ constructor(triggers: Triggers, baseUrl: string, options: Required<HttpTriggerTransformerOptions>, modifiers?: FunctionModifiers);
14
+ getTransformer(): ts.TransformerFactory<ts.Node>;
15
+ getVisitor(triggers: Triggers, context: ts.TransformationContext): ts.Visitor;
16
+ }