@metacall/protocol 0.1.24 → 0.1.26

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/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # MetaCall Protocol
2
+
3
+ This repository contains the protocol implementation for MetaCall FaaS. It is a client that allows deploying to [MetaCall FaaS](https://dashboard.metacall.io) or its [open source reimplementation](https://github.com/metacall/faas) written in TypeScript.
4
+
5
+ ## Documentation
6
+
7
+ Explore the detailed documentation for the MetaCall Protocol in the [doc](doc) directory. It provides comprehensive information on the protocol, its implementation details, and best practices for integration.
8
+
9
+ ## [Core](https://github.com/metacall/core)
10
+
11
+ The ultimate polyglot programming experience.
12
+
13
+ ## [Deploy](https://github.com/metacall/deploy)
14
+
15
+ Tool for deploying into MetaCall FaaS platform.
16
+
17
+ ## [Examples](https://github.com/metacall/examples)
18
+
19
+ A collection of use cases and examples to be deployed in MetaCall.
20
+
21
+ ## [FaaS](https://github.com/metacall/faas)
22
+
23
+ The FaaS platform reimplementation for MetaCall.
24
+
25
+ ## Testing
26
+
27
+ The [test](test) directory contains various tests for the MetaCall Protocol. These tests are designed to ensure the reliability and correctness of the protocol implementation. If you encounter any issues or inconsistencies, please report them by opening an [issue](https://github.com/metacall/protocol-repo/issues).
28
+
29
+ ## Contributing
30
+
31
+ We welcome contributions from the community. If you have ideas, suggestions, or want to report a bug, please feel free to open an [issue](https://github.com/metacall/protocol/issues) or submit a [pull request](https://github.com/metacall/protocol/pulls).
32
+ ## License
33
+
34
+ This repository is licensed under the [Apache License, Version 2.0](LICENSE). Feel free to use, modify, and distribute the code in accordance with the terms specified in the license.
@@ -0,0 +1,9 @@
1
+ export * from './deployment';
2
+ export * from './language';
3
+ export * from './login';
4
+ export * from './package';
5
+ export * from './plan';
6
+ export * from './token';
7
+ import metacallAPI from './protocol';
8
+ export * from './protocol';
9
+ export default metacallAPI;
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ __exportStar(require("./deployment"), exports);
17
+ __exportStar(require("./language"), exports);
18
+ __exportStar(require("./login"), exports);
19
+ __exportStar(require("./package"), exports);
20
+ __exportStar(require("./plan"), exports);
21
+ __exportStar(require("./token"), exports);
22
+ const protocol_1 = __importDefault(require("./protocol"));
23
+ __exportStar(require("./protocol"), exports);
24
+ exports.default = protocol_1.default;
package/dist/package.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { MetaCallJSON } from './deployment';
2
2
  export declare const findFilesPath: (path?: string, ignoreFiles?: string[]) => Promise<string[]>;
3
+ export declare const pathIsMetaCallJson: (path: string) => boolean;
3
4
  export declare const findMetaCallJsons: (files: string[]) => string[];
4
5
  export declare const findRunners: (files: string[]) => Set<string>;
5
6
  export declare enum PackageError {
package/dist/package.js CHANGED
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.generateJsonsFromFiles = exports.generatePackage = exports.PackageError = exports.findRunners = exports.findMetaCallJsons = exports.findFilesPath = void 0;
19
+ exports.generateJsonsFromFiles = exports.generatePackage = exports.PackageError = exports.findRunners = exports.findMetaCallJsons = exports.pathIsMetaCallJson = exports.findFilesPath = void 0;
20
20
  const ignore_walk_1 = __importDefault(require("ignore-walk"));
21
21
  const path_1 = require("path");
22
22
  const language_1 = require("./language");
@@ -28,7 +28,8 @@ const findFilesPath = async (path = process.cwd(), ignoreFiles = ['.gitignore'])
28
28
  })).filter(x => !x.startsWith('.git'));
29
29
  exports.findFilesPath = findFilesPath;
30
30
  const pathIsMetaCallJson = (path) => !!/^metacall(-.+)?\.json$/.exec(path_1.basename(path));
31
- const findMetaCallJsons = (files) => files.filter(pathIsMetaCallJson);
31
+ exports.pathIsMetaCallJson = pathIsMetaCallJson;
32
+ const findMetaCallJsons = (files) => files.filter(exports.pathIsMetaCallJson);
32
33
  exports.findMetaCallJsons = findMetaCallJsons;
33
34
  const findRunners = (files) => {
34
35
  const runners = new Set();
@@ -10,7 +10,10 @@ export interface SubscriptionDeploy {
10
10
  date: number;
11
11
  deploy: string;
12
12
  }
13
- export declare type ResourceType = 'Package' | 'Repository';
13
+ export declare enum ResourceType {
14
+ Package = "Package",
15
+ Repository = "Repository"
16
+ }
14
17
  export interface AddResponse {
15
18
  id: string;
16
19
  }
@@ -24,7 +27,7 @@ export interface API {
24
27
  listSubscriptions(): Promise<SubscriptionMap>;
25
28
  listSubscriptionsDeploys(): Promise<SubscriptionDeploy[]>;
26
29
  inspect(): Promise<Deployment[]>;
27
- upload(name: string, blob: unknown, jsons: MetaCallJSON[], runners: string[]): Promise<string>;
30
+ upload(name: string, blob: unknown, jsons?: MetaCallJSON[], runners?: string[]): Promise<string>;
28
31
  add(url: string, branch: string, jsons: MetaCallJSON[]): Promise<AddResponse>;
29
32
  deploy(name: string, env: {
30
33
  name: string;
package/dist/protocol.js CHANGED
@@ -22,12 +22,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.isProtocolError = void 0;
25
+ exports.ResourceType = exports.isProtocolError = void 0;
26
26
  const axios_1 = __importDefault(require("axios"));
27
27
  const form_data_1 = __importDefault(require("form-data"));
28
28
  const deployment_1 = require("./deployment");
29
29
  const isProtocolError = (err) => axios_1.default.isAxiosError(err);
30
30
  exports.isProtocolError = isProtocolError;
31
+ var ResourceType;
32
+ (function (ResourceType) {
33
+ ResourceType["Package"] = "Package";
34
+ ResourceType["Repository"] = "Repository";
35
+ })(ResourceType = exports.ResourceType || (exports.ResourceType = {}));
31
36
  exports.default = (token, baseURL) => {
32
37
  const api = {
33
38
  refresh: () => axios_1.default
@@ -71,6 +76,7 @@ exports.default = (token, baseURL) => {
71
76
  })
72
77
  .then(res => res.data),
73
78
  upload: async (name, blob, jsons = [], runners = []) => {
79
+ var _a, _b;
74
80
  const fd = new form_data_1.default();
75
81
  fd.append('id', name);
76
82
  fd.append('type', 'application/x-zip-compressed');
@@ -83,7 +89,7 @@ exports.default = (token, baseURL) => {
83
89
  const res = await axios_1.default.post(baseURL + '/api/package/create', fd, {
84
90
  headers: {
85
91
  Authorization: 'jwt ' + token,
86
- ...fd.getHeaders()
92
+ ...((_b = (_a = fd.getHeaders) === null || _a === void 0 ? void 0 : _a.call(fd)) !== null && _b !== void 0 ? _b : {}) // operator chaining to make it compatible with frontend
87
93
  }
88
94
  });
89
95
  return res.data;
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@metacall/protocol",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Tool for deploying into MetaCall FaaS platform.",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js",
7
+ ".": "./dist/index.js",
7
8
  "./package.json": "./package.json"
8
9
  },
9
10
  "typesVersions": {
10
11
  "*": {
11
12
  "*": [
12
13
  "dist/*.d.ts"
14
+ ],
15
+ ".": [
16
+ "./dist/index.d.ts"
13
17
  ]
14
18
  }
15
19
  },
@@ -81,8 +85,6 @@
81
85
  }
82
86
  },
83
87
  "dependencies": {
84
- "@types/ignore-walk": "^4.0.0",
85
- "@types/jsonwebtoken": "^8.5.8",
86
88
  "axios": "^0.21.0",
87
89
  "form-data": "^3.0.0",
88
90
  "ignore-walk": "^3.0.4",
@@ -90,7 +92,9 @@
90
92
  },
91
93
  "devDependencies": {
92
94
  "@types/express": "^4.17.13",
93
- "@types/mocha": "^8.2.2",
95
+ "@types/ignore-walk": "^4.0.0",
96
+ "@types/jsonwebtoken": "^8.5.8",
97
+ "@types/mocha": "^8.2.3",
94
98
  "@types/node": "^14.14.7",
95
99
  "@types/swagger-ui-express": "^4.1.3",
96
100
  "@types/yamljs": "^0.2.31",
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from './deployment';
2
+ export * from './language';
3
+ export * from './login';
4
+ export * from './package';
5
+ export * from './plan';
6
+ export * from './token';
7
+ import metacallAPI from './protocol';
8
+ export * from './protocol';
9
+ export default metacallAPI;
package/src/package.ts CHANGED
@@ -30,7 +30,7 @@ export const findFilesPath = async (
30
30
  })
31
31
  ).filter(x => !x.startsWith('.git'));
32
32
 
33
- const pathIsMetaCallJson = (path: string): boolean =>
33
+ export const pathIsMetaCallJson = (path: string): boolean =>
34
34
  !!/^metacall(-.+)?\.json$/.exec(basename(path));
35
35
 
36
36
  export const findMetaCallJsons = (files: string[]): string[] =>
package/src/protocol.ts CHANGED
@@ -37,7 +37,10 @@ export interface SubscriptionDeploy {
37
37
  deploy: string;
38
38
  }
39
39
 
40
- export type ResourceType = 'Package' | 'Repository';
40
+ export enum ResourceType {
41
+ Package = 'Package',
42
+ Repository = 'Repository'
43
+ }
41
44
 
42
45
  export interface AddResponse {
43
46
  id: string;
@@ -57,8 +60,8 @@ export interface API {
57
60
  upload(
58
61
  name: string,
59
62
  blob: unknown,
60
- jsons: MetaCallJSON[],
61
- runners: string[]
63
+ jsons?: MetaCallJSON[],
64
+ runners?: string[]
62
65
  ): Promise<string>;
63
66
  add(
64
67
  url: string,
@@ -171,7 +174,7 @@ export default (token: string, baseURL: string): API => {
171
174
  {
172
175
  headers: {
173
176
  Authorization: 'jwt ' + token,
174
- ...fd.getHeaders()
177
+ ...(fd.getHeaders?.() ?? {}) // operator chaining to make it compatible with frontend
175
178
  }
176
179
  }
177
180
  );