@teleporthq/teleport-next-revalidate-api 0.30.0-alpha.0
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/LICENSE +21 -0
- package/dist/cjs/component-plugin.d.ts +9 -0
- package/dist/cjs/component-plugin.d.ts.map +1 -0
- package/dist/cjs/component-plugin.js +102 -0
- package/dist/cjs/component-plugin.js.map +1 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +120 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/utils.d.ts +5 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +75 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/component-plugin.d.ts +9 -0
- package/dist/esm/component-plugin.d.ts.map +1 -0
- package/dist/esm/component-plugin.js +75 -0
- package/dist/esm/component-plugin.js.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +114 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/utils.d.ts +5 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +46 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +34 -0
- package/src/component-plugin.ts +104 -0
- package/src/index.ts +73 -0
- package/src/utils.ts +77 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 teleporthq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentPluginFactory, ProjectUIDL } from '@teleporthq/teleport-types';
|
|
2
|
+
interface NextCacheValidationProps {
|
|
3
|
+
routeMappers: Record<string, string[]>;
|
|
4
|
+
webhook: ProjectUIDL['resources']['cache']['webhook'];
|
|
5
|
+
cacheHandlerSecret?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createNextCacheValidationPlugin: ComponentPluginFactory<NextCacheValidationProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=component-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-plugin.d.ts","sourceRoot":"","sources":["../../src/component-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EAEtB,WAAW,EACZ,MAAM,4BAA4B,CAAA;AAInC,UAAU,wBAAwB;IAChC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAA;IACrD,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,eAAO,MAAM,+BAA+B,EAAE,sBAAsB,CAAC,wBAAwB,CAuF5F,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (_) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.createNextCacheValidationPlugin = void 0;
|
|
63
|
+
var teleport_types_1 = require("@teleporthq/teleport-types");
|
|
64
|
+
var types = __importStar(require("@babel/types"));
|
|
65
|
+
var utils_1 = require("./utils");
|
|
66
|
+
var createNextCacheValidationPlugin = function (config) {
|
|
67
|
+
var webhook = config.webhook, _a = config.routeMappers, routeMappers = _a === void 0 ? {} : _a, cacheHandlerSecret = config.cacheHandlerSecret;
|
|
68
|
+
var cacheValidationPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var dependencies, chunks, webhookHandlerContent, componentChunkContent;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
dependencies = structure.dependencies, chunks = structure.chunks;
|
|
72
|
+
webhookHandlerContent = [
|
|
73
|
+
types.expressionStatement(types.awaitExpression(types.callExpression(types.identifier(webhook.name), [
|
|
74
|
+
types.identifier('req'),
|
|
75
|
+
(0, utils_1.generateCallbackExpression)(routeMappers),
|
|
76
|
+
]))),
|
|
77
|
+
(0, utils_1.generateResponseWithStatus)(200, true),
|
|
78
|
+
];
|
|
79
|
+
if (cacheHandlerSecret) {
|
|
80
|
+
webhookHandlerContent.unshift(types.ifStatement(types.binaryExpression('!==', types.memberExpression(types.memberExpression(types.identifier('process'), types.identifier('env'), false, true), types.identifier(cacheHandlerSecret), false), types.memberExpression(types.memberExpression(types.identifier('req'), types.identifier('query')), types.stringLiteral(cacheHandlerSecret), true, true)), types.blockStatement([(0, utils_1.generateResponseWithStatus)(401, false)])));
|
|
81
|
+
}
|
|
82
|
+
componentChunkContent = types.exportDefaultDeclaration(types.functionDeclaration(types.identifier('handler'), [types.identifier('req'), types.identifier('res')], types.blockStatement([
|
|
83
|
+
types.tryStatement(types.blockStatement(webhookHandlerContent), types.catchClause(types.identifier('error'), types.blockStatement([
|
|
84
|
+
types.expressionStatement(types.callExpression(types.memberExpression(types.identifier('console'), types.identifier('log')), [types.identifier('error')])),
|
|
85
|
+
(0, utils_1.generateResponseWithStatus)(500, false),
|
|
86
|
+
]))),
|
|
87
|
+
]), false, true));
|
|
88
|
+
chunks.push({
|
|
89
|
+
name: 'revalidateChunk',
|
|
90
|
+
type: teleport_types_1.ChunkType.AST,
|
|
91
|
+
fileType: teleport_types_1.FileType.JS,
|
|
92
|
+
content: componentChunkContent,
|
|
93
|
+
linkAfter: ['import-local', 'import-lib', 'import-pack'],
|
|
94
|
+
});
|
|
95
|
+
dependencies[webhook.name] = webhook.dependency;
|
|
96
|
+
return [2 /*return*/, structure];
|
|
97
|
+
});
|
|
98
|
+
}); };
|
|
99
|
+
return cacheValidationPlugin;
|
|
100
|
+
};
|
|
101
|
+
exports.createNextCacheValidationPlugin = createNextCacheValidationPlugin;
|
|
102
|
+
//# sourceMappingURL=component-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-plugin.js","sourceRoot":"","sources":["../../src/component-plugin.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProjectPlugin, ProjectPluginStructure } from '@teleporthq/teleport-types';
|
|
2
|
+
export declare class ProjectPluginRevalidateAPI implements ProjectPlugin {
|
|
3
|
+
private routeMappers;
|
|
4
|
+
private cacheHandlerPath;
|
|
5
|
+
private cacheHandlerSecret;
|
|
6
|
+
constructor(params?: {
|
|
7
|
+
routeMappers?: Record<string, string[]>;
|
|
8
|
+
cacheHandlerPath?: string[];
|
|
9
|
+
cacheHandlerSecret?: string;
|
|
10
|
+
});
|
|
11
|
+
runAfter(structure: ProjectPluginStructure): Promise<ProjectPluginStructure>;
|
|
12
|
+
runBefore(structure: ProjectPluginStructure): Promise<ProjectPluginStructure>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAMlF,qBAAa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,kBAAkB,CAAsB;gBAG9C,MAAM,GAAE;QACN,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACvC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;KACvB;IAeF,QAAQ,CAAC,SAAS,EAAE,sBAAsB;IAsC1C,SAAS,CAAC,SAAS,EAAE,sBAAsB;CAGlD"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.ProjectPluginRevalidateAPI = void 0;
|
|
54
|
+
var teleport_component_generator_1 = require("@teleporthq/teleport-component-generator");
|
|
55
|
+
var component_plugin_1 = require("./component-plugin");
|
|
56
|
+
var teleport_plugin_import_statements_1 = __importDefault(require("@teleporthq/teleport-plugin-import-statements"));
|
|
57
|
+
var teleport_postprocessor_prettier_js_1 = __importDefault(require("@teleporthq/teleport-postprocessor-prettier-js"));
|
|
58
|
+
var ProjectPluginRevalidateAPI = /** @class */ (function () {
|
|
59
|
+
function ProjectPluginRevalidateAPI(params) {
|
|
60
|
+
if (params === void 0) { params = {}; }
|
|
61
|
+
this.routeMappers = {};
|
|
62
|
+
this.cacheHandlerPath = ['pages', 'api'];
|
|
63
|
+
this.cacheHandlerSecret = null;
|
|
64
|
+
var routeMappers = params.routeMappers, cacheHandlerPath = params.cacheHandlerPath, cacheHandlerSecret = params.cacheHandlerSecret;
|
|
65
|
+
if (routeMappers) {
|
|
66
|
+
this.routeMappers = routeMappers;
|
|
67
|
+
}
|
|
68
|
+
if (cacheHandlerPath) {
|
|
69
|
+
this.cacheHandlerPath = cacheHandlerPath;
|
|
70
|
+
}
|
|
71
|
+
if (cacheHandlerSecret) {
|
|
72
|
+
this.cacheHandlerSecret = cacheHandlerSecret;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
ProjectPluginRevalidateAPI.prototype.runAfter = function (structure) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var uidl, files, generator, _c, cacheHandlerFiles, cacheHandlerDependencies;
|
|
79
|
+
return __generator(this, function (_d) {
|
|
80
|
+
switch (_d.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
uidl = structure.uidl, files = structure.files;
|
|
83
|
+
if (!((_b = (_a = uidl.resources.cache) === null || _a === void 0 ? void 0 : _a.webhook) === null || _b === void 0 ? void 0 : _b.dependency)) {
|
|
84
|
+
return [2 /*return*/, structure];
|
|
85
|
+
}
|
|
86
|
+
generator = (0, teleport_component_generator_1.createComponentGenerator)();
|
|
87
|
+
generator.addPlugin((0, component_plugin_1.createNextCacheValidationPlugin)({
|
|
88
|
+
routeMappers: this.routeMappers,
|
|
89
|
+
cacheHandlerSecret: this.cacheHandlerSecret,
|
|
90
|
+
webhook: uidl.resources.cache.webhook,
|
|
91
|
+
}));
|
|
92
|
+
generator.addPlugin(teleport_plugin_import_statements_1.default);
|
|
93
|
+
generator.addPostProcessor(teleport_postprocessor_prettier_js_1.default);
|
|
94
|
+
return [4 /*yield*/, generator.generateComponent(__assign(__assign({}, uidl.root), { name: 'revalidate' }), {
|
|
95
|
+
skipValidation: true,
|
|
96
|
+
skipNavlinkResolver: true,
|
|
97
|
+
})];
|
|
98
|
+
case 1:
|
|
99
|
+
_c = _d.sent(), cacheHandlerFiles = _c.files, cacheHandlerDependencies = _c.dependencies;
|
|
100
|
+
structure.dependencies = __assign(__assign({}, structure.dependencies), cacheHandlerDependencies);
|
|
101
|
+
files.set('revalidate', {
|
|
102
|
+
path: this.cacheHandlerPath,
|
|
103
|
+
files: cacheHandlerFiles,
|
|
104
|
+
});
|
|
105
|
+
return [2 /*return*/, structure];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
ProjectPluginRevalidateAPI.prototype.runBefore = function (structure) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, structure];
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
return ProjectPluginRevalidateAPI;
|
|
118
|
+
}());
|
|
119
|
+
exports.ProjectPluginRevalidateAPI = ProjectPluginRevalidateAPI;
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yFAAmF;AACnF,uDAAoE;AACpE,oHAAkF;AAClF,sHAA6E;AAE7E;IAKE,oCACE,MAIM;QAJN,uBAAA,EAAA,WAIM;QATA,iBAAY,GAA6B,EAAE,CAAA;QAC3C,qBAAgB,GAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC7C,uBAAkB,GAAkB,IAAI,CAAA;QAStC,IAAA,YAAY,GAA2C,MAAM,aAAjD,EAAE,gBAAgB,GAAyB,MAAM,iBAA/B,EAAE,kBAAkB,GAAK,MAAM,mBAAX,CAAW;QACrE,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;SACjC;QACD,IAAI,gBAAgB,EAAE;YACpB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;SACzC;QAED,IAAI,kBAAkB,EAAE;YACtB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;SAC7C;IACH,CAAC;IAEK,6CAAQ,GAAd,UAAe,SAAiC;;;;;;;wBACtC,IAAI,GAAY,SAAS,KAArB,EAAE,KAAK,GAAK,SAAS,MAAd,CAAc;wBACjC,IAAI,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,KAAK,0CAAE,OAAO,0CAAE,UAAU,CAAA,EAAE;4BAC9C,sBAAO,SAAS,EAAA;yBACjB;wBACK,SAAS,GAAG,IAAA,uDAAwB,GAAE,CAAA;wBAC5C,SAAS,CAAC,SAAS,CACjB,IAAA,kDAA+B,EAAC;4BAC9B,YAAY,EAAE,IAAI,CAAC,YAAY;4BAC/B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;4BAC3C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO;yBACtC,CAAC,CACH,CAAA;wBACD,SAAS,CAAC,SAAS,CAAC,2CAAsB,CAAC,CAAA;wBAC3C,SAAS,CAAC,gBAAgB,CAAC,4CAAgB,CAAC,CAAA;wBAG1C,qBAAM,SAAS,CAAC,iBAAiB,uBAE1B,IAAI,CAAC,IAAI,KACZ,IAAI,EAAE,YAAY,KAEpB;gCACE,cAAc,EAAE,IAAI;gCACpB,mBAAmB,EAAE,IAAI;6BAC1B,CACF,EAAA;;wBAVG,KACJ,SASC,EAVY,iBAAiB,WAAA,EAAgB,wBAAwB,kBAAA;wBAYxE,SAAS,CAAC,YAAY,yBAAQ,SAAS,CAAC,YAAY,GAAK,wBAAwB,CAAE,CAAA;wBAEnF,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE;4BACtB,IAAI,EAAE,IAAI,CAAC,gBAAgB;4BAC3B,KAAK,EAAE,iBAAiB;yBACzB,CAAC,CAAA;wBAEF,sBAAO,SAAS,EAAA;;;;KACjB;IAEK,8CAAS,GAAf,UAAgB,SAAiC;;;gBAC/C,sBAAO,SAAS,EAAA;;;KACjB;IACH,iCAAC;AAAD,CAAC,AAlED,IAkEC;AAlEY,gEAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/helper.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../src/utils.ts","../../src/component-plugin.ts","../../../teleport-component-generator/dist/cjs/index.d.ts","../../../teleport-plugin-import-statements/dist/cjs/index.d.ts","../../../teleport-postprocessor-prettier-js/dist/cjs/index.d.ts","../../src/index.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"5075b36ab861c8c0c45377cb8c96270d7c65f0eeaf105d53fac6850da61f1027","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"fd0f56a96d995bf07780490eb65da40e9fbdf80c1ddc89fb5ef837d91849c6d8","9ebbd52e628b867414be6227fb1116170e9f025ad4da491fb8f3ca3084abfe97","2063c91c3185f6208df21dbd360b5fe20ee4db1d82e3abc1a543d05ba5eab934","71a689048584cde03cb508408ae7c3b04ad8f10af887865e8b65c27ed9d91488","c14f880e138325787e965144e75c01b33202c9214c088822fb014e60f4831d9a","6ba1631f84ef4507073189c4ada06d6de8bac89375ea3b49e34e49006cc44a3f","2ff9995137f3e5d68971388ec58af0c79721626323884513f9f5e2e996ac1fdd","a7ac9fd7ac1c940b697ba3fed0fdf70d13cb31fab42e5aa49f72eaeb06df174c","991a1469a744cab4c7430a85229b3a616b24e3b2a0ca3fb1bf4491e8d44d5226","dbd4e3c1c81a350659f3ba09d931a953c37f6ea39d9e5880decfb22130fbbf70","c8d113d442ce7d757244e9ca2616396c5d9bd5076d3f14c66851d1561d34b943","49ecfc82833cce5065bf13363e7049baa284df8c7d4f141759d6910fc00d31cc","212355c1cc804424f1eae0d011a09d24cdb63b21f8cf0863ef197b6518919983","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"2f6c9750131d5d2fdaba85c164a930dc07d2d7e7e8970b89d32864aa6c72620c","affectsGlobalScope":true},"56d13f223ab40f71840795f5bef2552a397a70666ee60878222407f3893fb8d0",{"version":"aeeee3998c5a730f8689f04038d41cf4245c9edbf6ef29a698e45b36e399b8ed","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","90b94d3d2aa3432cc9dd2d15f56a38b166163fc555404c74243e1af29c5549d8","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","c993aac3b6d4a4620ef9651497069eb84806a131420e4f158ea9396fb8eb9b8c","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","e3b886bacdd1fbf1f72e654596c80a55c7bc1d10bdf464aaf52f45ecd243862f","d2f5c67858e65ebb932c2f4bd2af646f5764e8ad7f1e4fbe942a0b5ea05dc0e7","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","7f249c599e7a9335dd8e94a4bfe63f00e911756c3c23f77cdb6ef0ec4d479e4a",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"2cabc86ea4f972f2c8386903eccb8c19e2f2370fb9808b66dd8759c1f2ab30c7","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","945a841f9a591197154c85386bc5a1467d42d325104bb36db51bc566bbb240be","10c39ce1df102994b47d4bc0c71aa9a6aea76f4651a5ec51914431f50bc883a1",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","3fa48484c65913004d5abb5c0f917b61ea4684f32d05bb28c1ecfa5f05a9ed12","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"33eee034727baf564056b4ea719075c23d3b4767d0b5f9c6933b81f3d77774d2","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"127803f77e0dfee84b031b83ea7776875c6c4c89e11a81d00299ff58f163f0e2","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4",{"version":"dd9ea469d1bfaf589c6a196275d35cb1aa14014707c2c46d920c7b921e8f5bca","affectsGlobalScope":true},"badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1503a452a67127e5c2da794d1c7c44344d5038373aae16c9b03ac964db159edd","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":1,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96],[96,108,110],[96,104,105],[96,104,105,106,107],[96,109],[96,111],[53,96],[56,96],[57,62,96],[58,68,69,76,85,95,96],[58,59,68,76,96],[60,96],[61,62,69,77,96],[62,85,92,96],[63,65,68,76,96],[64,96],[65,66,96],[67,68,96],[68,96],[68,69,70,85,95,96],[68,69,70,85,96],[71,76,85,95,96],[68,69,71,72,76,85,92,95,96],[71,73,85,92,95,96],[53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102],[68,74,96],[75,95,96],[65,68,76,85,96],[77,96],[78,96],[56,79,96],[80,94,96,100],[81,96],[82,96],[68,83,96],[83,84,96,98],[68,85,86,87,96],[85,87,96],[85,86,96],[88,96],[89,96],[68,90,91,96],[90,91,96],[62,76,92,96],[93,96],[76,94,96],[57,71,82,95,96],[62,96],[85,96,97],[96,98],[96,99],[57,62,68,70,79,85,95,96,98,100],[85,96,101],[45,96],[45,46,47,96],[45,48,49,50,51,96],[46,96],[41,96],[41,42,43,44,96],[40,96],[40,41,96]],"referencedMap":[[46,1],[111,2],[104,1],[106,3],[108,4],[107,3],[105,1],[110,5],[109,1],[112,6],[53,7],[54,7],[56,8],[57,9],[58,10],[59,11],[60,12],[61,13],[62,14],[63,15],[64,16],[65,17],[66,17],[67,18],[68,19],[69,20],[70,21],[55,1],[102,1],[71,22],[72,23],[73,24],[103,25],[74,26],[75,27],[76,28],[77,29],[78,30],[79,31],[80,32],[81,33],[82,34],[83,35],[84,36],[85,37],[87,38],[86,39],[88,40],[89,41],[90,42],[91,43],[92,44],[93,45],[94,46],[95,47],[96,48],[97,49],[98,50],[99,51],[100,52],[101,53],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[49,54],[50,54],[51,54],[48,55],[52,56],[47,57],[43,1],[42,58],[40,1],[45,59],[41,60],[44,61]],"exportedModulesMap":[[46,1],[111,2],[104,1],[106,3],[108,4],[107,3],[105,1],[110,5],[109,1],[112,6],[53,7],[54,7],[56,8],[57,9],[58,10],[59,11],[60,12],[61,13],[62,14],[63,15],[64,16],[65,17],[66,17],[67,18],[68,19],[69,20],[70,21],[55,1],[102,1],[71,22],[72,23],[73,24],[103,25],[74,26],[75,27],[76,28],[77,29],[78,30],[79,31],[80,32],[81,33],[82,34],[83,35],[84,36],[85,37],[87,38],[86,39],[88,40],[89,41],[90,42],[91,43],[92,44],[93,45],[94,46],[95,47],[96,48],[97,49],[98,50],[99,51],[100,52],[101,53],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[49,54],[50,54],[51,54],[48,55],[52,56],[47,57],[43,1],[42,58],[40,1],[45,59],[41,60],[44,61]],"semanticDiagnosticsPerFile":[46,111,104,106,108,107,105,110,109,112,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,55,102,71,72,73,103,74,75,76,77,78,79,80,81,82,83,84,85,87,86,88,89,90,91,92,93,94,95,96,97,98,99,100,101,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,49,50,51,48,52,47,43,42,40,45,41,44]},"version":"4.6.2"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as types from '@babel/types';
|
|
2
|
+
export declare const generateResponseWithStatus: (status: number, revalidationStatus: boolean) => types.ReturnStatement;
|
|
3
|
+
export declare const appendDataToObjectExpression: (expression: string) => string;
|
|
4
|
+
export declare const generateCallbackExpression: (routeMappings: Record<string, string[]>) => types.ArrowFunctionExpression;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,eAAO,MAAM,0BAA0B,WAC7B,MAAM,sBACM,OAAO,KAC1B,MAAM,eAoBR,CAAA;AAED,eAAO,MAAM,4BAA4B,eAAgB,MAAM,KAAG,MAIjE,CAAA;AAED,eAAO,MAAM,0BAA0B,kBACtB,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,KACtC,MAAM,uBAyCR,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.generateCallbackExpression = exports.appendDataToObjectExpression = exports.generateResponseWithStatus = void 0;
|
|
36
|
+
var types = __importStar(require("@babel/types"));
|
|
37
|
+
var generateResponseWithStatus = function (status, revalidationStatus) {
|
|
38
|
+
return types.returnStatement(types.callExpression(types.memberExpression(types.callExpression(types.memberExpression(types.identifier('res'), types.identifier('status')), [types.numericLiteral(status)]), types.identifier('json')), [
|
|
39
|
+
types.objectExpression([
|
|
40
|
+
types.objectProperty(types.identifier('revalidated'), types.booleanLiteral(revalidationStatus)),
|
|
41
|
+
]),
|
|
42
|
+
]));
|
|
43
|
+
};
|
|
44
|
+
exports.generateResponseWithStatus = generateResponseWithStatus;
|
|
45
|
+
var appendDataToObjectExpression = function (expression) {
|
|
46
|
+
var regex = /\${(.*?)}/g;
|
|
47
|
+
var result = expression.replace(regex, function (_, p1) { return "${data.".concat(p1, "}"); });
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
exports.appendDataToObjectExpression = appendDataToObjectExpression;
|
|
51
|
+
var generateCallbackExpression = function (routeMappings) {
|
|
52
|
+
var switchCases = Object.entries(routeMappings).map(function (_a) {
|
|
53
|
+
var contentType = _a[0], paths = _a[1];
|
|
54
|
+
return types.switchCase(types.stringLiteral(contentType), __spreadArray(__spreadArray([], paths.map(function (dynamicPath) {
|
|
55
|
+
return types.expressionStatement(types.callExpression(types.memberExpression(types.identifier('res'), types.identifier('revalidate')), [
|
|
56
|
+
types.templateLiteral([
|
|
57
|
+
types.templateElement({
|
|
58
|
+
raw: (0, exports.appendDataToObjectExpression)(dynamicPath),
|
|
59
|
+
cooked: (0, exports.appendDataToObjectExpression)(dynamicPath),
|
|
60
|
+
}),
|
|
61
|
+
], []),
|
|
62
|
+
]));
|
|
63
|
+
}), true), [
|
|
64
|
+
types.breakStatement(),
|
|
65
|
+
], false));
|
|
66
|
+
});
|
|
67
|
+
switchCases.push(types.switchCase(null, [
|
|
68
|
+
types.throwStatement(types.newExpression(types.identifier('Error'), [
|
|
69
|
+
types.stringLiteral('Invalid content type'),
|
|
70
|
+
])),
|
|
71
|
+
]));
|
|
72
|
+
return types.arrowFunctionExpression([types.identifier('data'), types.identifier('contentType')], types.blockStatement([types.switchStatement(types.identifier('contentType'), switchCases)]));
|
|
73
|
+
};
|
|
74
|
+
exports.generateCallbackExpression = generateCallbackExpression;
|
|
75
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqC;AAE9B,IAAM,0BAA0B,GAAG,UACxC,MAAc,EACd,kBAA2B;IAE3B,OAAO,KAAK,CAAC,eAAe,CAC1B,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CACpB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAC3E,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAC/B,EACD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CACzB,EACD;QACE,KAAK,CAAC,gBAAgB,CAAC;YACrB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAC/B,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CACzC;SACF,CAAC;KACH,CACF,CACF,CAAA;AACH,CAAC,CAAA;AAvBY,QAAA,0BAA0B,8BAuBtC;AAEM,IAAM,4BAA4B,GAAG,UAAC,UAAkB;IAC7D,IAAM,KAAK,GAAG,YAAY,CAAA;IAC1B,IAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,UAAC,CAAC,EAAE,EAAE,IAAK,OAAA,iBAAW,EAAE,MAAG,EAAhB,CAAgB,CAAC,CAAA;IACrE,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAJY,QAAA,4BAA4B,gCAIxC;AAEM,IAAM,0BAA0B,GAAG,UACxC,aAAuC;IAEvC,IAAM,WAAW,GAAuB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CACvE,UAAC,EAAoB;YAAnB,WAAW,QAAA,EAAE,KAAK,QAAA;QAClB,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,kCACnD,KAAK,CAAC,GAAG,CAAC,UAAC,WAAW;YACvB,OAAO,KAAK,CAAC,mBAAmB,CAC9B,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAC/E;gBACE,KAAK,CAAC,eAAe,CACnB;oBACE,KAAK,CAAC,eAAe,CAAC;wBACpB,GAAG,EAAE,IAAA,oCAA4B,EAAC,WAAW,CAAC;wBAC9C,MAAM,EAAE,IAAA,oCAA4B,EAAC,WAAW,CAAC;qBAClD,CAAC;iBACH,EACD,EAAE,CACH;aACF,CACF,CACF,CAAA;QACH,CAAC,CAAC;YACF,KAAK,CAAC,cAAc,EAAE;kBACtB,CAAA;IACJ,CAAC,CACF,CAAA;IAED,WAAW,CAAC,IAAI,CACd,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE;QACrB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC7C,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC;SAC5C,CAAC,CACH;KACF,CAAC,CACH,CAAA;IAED,OAAO,KAAK,CAAC,uBAAuB,CAClC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC3D,KAAK,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAC5F,CAAA;AACH,CAAC,CAAA;AA3CY,QAAA,0BAA0B,8BA2CtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentPluginFactory, ProjectUIDL } from '@teleporthq/teleport-types';
|
|
2
|
+
interface NextCacheValidationProps {
|
|
3
|
+
routeMappers: Record<string, string[]>;
|
|
4
|
+
webhook: ProjectUIDL['resources']['cache']['webhook'];
|
|
5
|
+
cacheHandlerSecret?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createNextCacheValidationPlugin: ComponentPluginFactory<NextCacheValidationProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=component-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-plugin.d.ts","sourceRoot":"","sources":["../../src/component-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EAEtB,WAAW,EACZ,MAAM,4BAA4B,CAAA;AAInC,UAAU,wBAAwB;IAChC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAA;IACrD,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,eAAO,MAAM,+BAA+B,EAAE,sBAAsB,CAAC,wBAAwB,CAuF5F,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { ChunkType, FileType, } from '@teleporthq/teleport-types';
|
|
38
|
+
import * as types from '@babel/types';
|
|
39
|
+
import { generateCallbackExpression, generateResponseWithStatus } from './utils';
|
|
40
|
+
export var createNextCacheValidationPlugin = function (config) {
|
|
41
|
+
var webhook = config.webhook, _a = config.routeMappers, routeMappers = _a === void 0 ? {} : _a, cacheHandlerSecret = config.cacheHandlerSecret;
|
|
42
|
+
var cacheValidationPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var dependencies, chunks, webhookHandlerContent, componentChunkContent;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
dependencies = structure.dependencies, chunks = structure.chunks;
|
|
46
|
+
webhookHandlerContent = [
|
|
47
|
+
types.expressionStatement(types.awaitExpression(types.callExpression(types.identifier(webhook.name), [
|
|
48
|
+
types.identifier('req'),
|
|
49
|
+
generateCallbackExpression(routeMappers),
|
|
50
|
+
]))),
|
|
51
|
+
generateResponseWithStatus(200, true),
|
|
52
|
+
];
|
|
53
|
+
if (cacheHandlerSecret) {
|
|
54
|
+
webhookHandlerContent.unshift(types.ifStatement(types.binaryExpression('!==', types.memberExpression(types.memberExpression(types.identifier('process'), types.identifier('env'), false, true), types.identifier(cacheHandlerSecret), false), types.memberExpression(types.memberExpression(types.identifier('req'), types.identifier('query')), types.stringLiteral(cacheHandlerSecret), true, true)), types.blockStatement([generateResponseWithStatus(401, false)])));
|
|
55
|
+
}
|
|
56
|
+
componentChunkContent = types.exportDefaultDeclaration(types.functionDeclaration(types.identifier('handler'), [types.identifier('req'), types.identifier('res')], types.blockStatement([
|
|
57
|
+
types.tryStatement(types.blockStatement(webhookHandlerContent), types.catchClause(types.identifier('error'), types.blockStatement([
|
|
58
|
+
types.expressionStatement(types.callExpression(types.memberExpression(types.identifier('console'), types.identifier('log')), [types.identifier('error')])),
|
|
59
|
+
generateResponseWithStatus(500, false),
|
|
60
|
+
]))),
|
|
61
|
+
]), false, true));
|
|
62
|
+
chunks.push({
|
|
63
|
+
name: 'revalidateChunk',
|
|
64
|
+
type: ChunkType.AST,
|
|
65
|
+
fileType: FileType.JS,
|
|
66
|
+
content: componentChunkContent,
|
|
67
|
+
linkAfter: ['import-local', 'import-lib', 'import-pack'],
|
|
68
|
+
});
|
|
69
|
+
dependencies[webhook.name] = webhook.dependency;
|
|
70
|
+
return [2 /*return*/, structure];
|
|
71
|
+
});
|
|
72
|
+
}); };
|
|
73
|
+
return cacheValidationPlugin;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=component-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-plugin.js","sourceRoot":"","sources":["../../src/component-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,SAAS,EAGT,QAAQ,GAET,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAQhF,MAAM,CAAC,IAAM,+BAA+B,GAAqD,UAC/F,MAAM;IAEE,IAAA,OAAO,GAA4C,MAAM,QAAlD,EAAE,KAA0C,MAAM,aAA/B,EAAjB,YAAY,mBAAG,EAAE,KAAA,EAAE,kBAAkB,GAAK,MAAM,mBAAX,CAAW;IAEjE,IAAM,qBAAqB,GAAoB,UAAO,SAAS;;;YACrD,YAAY,GAAa,SAAS,aAAtB,EAAE,MAAM,GAAK,SAAS,OAAd,CAAc;YAEpC,qBAAqB,GAAsB;gBAC/C,KAAK,CAAC,mBAAmB,CACvB,KAAK,CAAC,eAAe,CACnB,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACnD,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;oBACvB,0BAA0B,CAAC,YAAY,CAAC;iBACzC,CAAC,CACH,CACF;gBACD,0BAA0B,CAAC,GAAG,EAAE,IAAI,CAAC;aACtC,CAAA;YAED,IAAI,kBAAkB,EAAE;gBACtB,qBAAqB,CAAC,OAAO,CAC3B,KAAK,CAAC,WAAW,CACf,KAAK,CAAC,gBAAgB,CACpB,KAAK,EACL,KAAK,CAAC,gBAAgB,CACpB,KAAK,CAAC,gBAAgB,CACpB,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAC3B,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EACvB,KAAK,EACL,IAAI,CACL,EACD,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,EACpC,KAAK,CACN,EACD,KAAK,CAAC,gBAAgB,CACpB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAC1E,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,EACvC,IAAI,EACJ,IAAI,CACL,CACF,EACD,KAAK,CAAC,cAAc,CAAC,CAAC,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAC/D,CACF,CAAA;aACF;YAEK,qBAAqB,GAAG,KAAK,CAAC,wBAAwB,CAC1D,KAAK,CAAC,mBAAmB,CACvB,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAC3B,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAClD,KAAK,CAAC,cAAc,CAAC;gBACnB,KAAK,CAAC,YAAY,CAChB,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAC3C,KAAK,CAAC,WAAW,CACf,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EACzB,KAAK,CAAC,cAAc,CAAC;oBACnB,KAAK,CAAC,mBAAmB,CACvB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAC5E,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAC5B,CACF;oBACD,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC;iBACvC,CAAC,CACH,CACF;aACF,CAAC,EACF,KAAK,EACL,IAAI,CACL,CACF,CAAA;YAED,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,SAAS,CAAC,GAAG;gBACnB,QAAQ,EAAE,QAAQ,CAAC,EAAE;gBACrB,OAAO,EAAE,qBAAqB;gBAC9B,SAAS,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,aAAa,CAAC;aACzD,CAAC,CAAA;YAEF,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAA;YAE/C,sBAAO,SAAS,EAAA;;SACjB,CAAA;IAED,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProjectPlugin, ProjectPluginStructure } from '@teleporthq/teleport-types';
|
|
2
|
+
export declare class ProjectPluginRevalidateAPI implements ProjectPlugin {
|
|
3
|
+
private routeMappers;
|
|
4
|
+
private cacheHandlerPath;
|
|
5
|
+
private cacheHandlerSecret;
|
|
6
|
+
constructor(params?: {
|
|
7
|
+
routeMappers?: Record<string, string[]>;
|
|
8
|
+
cacheHandlerPath?: string[];
|
|
9
|
+
cacheHandlerSecret?: string;
|
|
10
|
+
});
|
|
11
|
+
runAfter(structure: ProjectPluginStructure): Promise<ProjectPluginStructure>;
|
|
12
|
+
runBefore(structure: ProjectPluginStructure): Promise<ProjectPluginStructure>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAMlF,qBAAa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,kBAAkB,CAAsB;gBAG9C,MAAM,GAAE;QACN,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACvC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;KACvB;IAeF,QAAQ,CAAC,SAAS,EAAE,sBAAsB;IAsC1C,SAAS,CAAC,SAAS,EAAE,sBAAsB;CAGlD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { createComponentGenerator } from '@teleporthq/teleport-component-generator';
|
|
49
|
+
import { createNextCacheValidationPlugin } from './component-plugin';
|
|
50
|
+
import importStatementsPlugin from '@teleporthq/teleport-plugin-import-statements';
|
|
51
|
+
import prettierJSPlugin from '@teleporthq/teleport-postprocessor-prettier-js';
|
|
52
|
+
var ProjectPluginRevalidateAPI = /** @class */ (function () {
|
|
53
|
+
function ProjectPluginRevalidateAPI(params) {
|
|
54
|
+
if (params === void 0) { params = {}; }
|
|
55
|
+
this.routeMappers = {};
|
|
56
|
+
this.cacheHandlerPath = ['pages', 'api'];
|
|
57
|
+
this.cacheHandlerSecret = null;
|
|
58
|
+
var routeMappers = params.routeMappers, cacheHandlerPath = params.cacheHandlerPath, cacheHandlerSecret = params.cacheHandlerSecret;
|
|
59
|
+
if (routeMappers) {
|
|
60
|
+
this.routeMappers = routeMappers;
|
|
61
|
+
}
|
|
62
|
+
if (cacheHandlerPath) {
|
|
63
|
+
this.cacheHandlerPath = cacheHandlerPath;
|
|
64
|
+
}
|
|
65
|
+
if (cacheHandlerSecret) {
|
|
66
|
+
this.cacheHandlerSecret = cacheHandlerSecret;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
ProjectPluginRevalidateAPI.prototype.runAfter = function (structure) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var uidl, files, generator, _c, cacheHandlerFiles, cacheHandlerDependencies;
|
|
73
|
+
return __generator(this, function (_d) {
|
|
74
|
+
switch (_d.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
uidl = structure.uidl, files = structure.files;
|
|
77
|
+
if (!((_b = (_a = uidl.resources.cache) === null || _a === void 0 ? void 0 : _a.webhook) === null || _b === void 0 ? void 0 : _b.dependency)) {
|
|
78
|
+
return [2 /*return*/, structure];
|
|
79
|
+
}
|
|
80
|
+
generator = createComponentGenerator();
|
|
81
|
+
generator.addPlugin(createNextCacheValidationPlugin({
|
|
82
|
+
routeMappers: this.routeMappers,
|
|
83
|
+
cacheHandlerSecret: this.cacheHandlerSecret,
|
|
84
|
+
webhook: uidl.resources.cache.webhook,
|
|
85
|
+
}));
|
|
86
|
+
generator.addPlugin(importStatementsPlugin);
|
|
87
|
+
generator.addPostProcessor(prettierJSPlugin);
|
|
88
|
+
return [4 /*yield*/, generator.generateComponent(__assign(__assign({}, uidl.root), { name: 'revalidate' }), {
|
|
89
|
+
skipValidation: true,
|
|
90
|
+
skipNavlinkResolver: true,
|
|
91
|
+
})];
|
|
92
|
+
case 1:
|
|
93
|
+
_c = _d.sent(), cacheHandlerFiles = _c.files, cacheHandlerDependencies = _c.dependencies;
|
|
94
|
+
structure.dependencies = __assign(__assign({}, structure.dependencies), cacheHandlerDependencies);
|
|
95
|
+
files.set('revalidate', {
|
|
96
|
+
path: this.cacheHandlerPath,
|
|
97
|
+
files: cacheHandlerFiles,
|
|
98
|
+
});
|
|
99
|
+
return [2 /*return*/, structure];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
ProjectPluginRevalidateAPI.prototype.runBefore = function (structure) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
return [2 /*return*/, structure];
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return ProjectPluginRevalidateAPI;
|
|
112
|
+
}());
|
|
113
|
+
export { ProjectPluginRevalidateAPI };
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAA;AACnF,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,sBAAsB,MAAM,+CAA+C,CAAA;AAClF,OAAO,gBAAgB,MAAM,gDAAgD,CAAA;AAE7E;IAKE,oCACE,MAIM;QAJN,uBAAA,EAAA,WAIM;QATA,iBAAY,GAA6B,EAAE,CAAA;QAC3C,qBAAgB,GAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC7C,uBAAkB,GAAkB,IAAI,CAAA;QAStC,IAAA,YAAY,GAA2C,MAAM,aAAjD,EAAE,gBAAgB,GAAyB,MAAM,iBAA/B,EAAE,kBAAkB,GAAK,MAAM,mBAAX,CAAW;QACrE,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;SACjC;QACD,IAAI,gBAAgB,EAAE;YACpB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;SACzC;QAED,IAAI,kBAAkB,EAAE;YACtB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;SAC7C;IACH,CAAC;IAEK,6CAAQ,GAAd,UAAe,SAAiC;;;;;;;wBACtC,IAAI,GAAY,SAAS,KAArB,EAAE,KAAK,GAAK,SAAS,MAAd,CAAc;wBACjC,IAAI,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,KAAK,0CAAE,OAAO,0CAAE,UAAU,CAAA,EAAE;4BAC9C,sBAAO,SAAS,EAAA;yBACjB;wBACK,SAAS,GAAG,wBAAwB,EAAE,CAAA;wBAC5C,SAAS,CAAC,SAAS,CACjB,+BAA+B,CAAC;4BAC9B,YAAY,EAAE,IAAI,CAAC,YAAY;4BAC/B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;4BAC3C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO;yBACtC,CAAC,CACH,CAAA;wBACD,SAAS,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;wBAC3C,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;wBAG1C,qBAAM,SAAS,CAAC,iBAAiB,uBAE1B,IAAI,CAAC,IAAI,KACZ,IAAI,EAAE,YAAY,KAEpB;gCACE,cAAc,EAAE,IAAI;gCACpB,mBAAmB,EAAE,IAAI;6BAC1B,CACF,EAAA;;wBAVG,KACJ,SASC,EAVY,iBAAiB,WAAA,EAAgB,wBAAwB,kBAAA;wBAYxE,SAAS,CAAC,YAAY,yBAAQ,SAAS,CAAC,YAAY,GAAK,wBAAwB,CAAE,CAAA;wBAEnF,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE;4BACtB,IAAI,EAAE,IAAI,CAAC,gBAAgB;4BAC3B,KAAK,EAAE,iBAAiB;yBACzB,CAAC,CAAA;wBAEF,sBAAO,SAAS,EAAA;;;;KACjB;IAEK,8CAAS,GAAf,UAAgB,SAAiC;;;gBAC/C,sBAAO,SAAS,EAAA;;;KACjB;IACH,iCAAC;AAAD,CAAC,AAlED,IAkEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/helper.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../src/utils.ts","../../src/component-plugin.ts","../../../teleport-component-generator/dist/cjs/index.d.ts","../../../teleport-plugin-import-statements/dist/cjs/index.d.ts","../../../teleport-postprocessor-prettier-js/dist/cjs/index.d.ts","../../src/index.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"5075b36ab861c8c0c45377cb8c96270d7c65f0eeaf105d53fac6850da61f1027","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"fd0f56a96d995bf07780490eb65da40e9fbdf80c1ddc89fb5ef837d91849c6d8","9ebbd52e628b867414be6227fb1116170e9f025ad4da491fb8f3ca3084abfe97","2063c91c3185f6208df21dbd360b5fe20ee4db1d82e3abc1a543d05ba5eab934","71a689048584cde03cb508408ae7c3b04ad8f10af887865e8b65c27ed9d91488","c14f880e138325787e965144e75c01b33202c9214c088822fb014e60f4831d9a","6ba1631f84ef4507073189c4ada06d6de8bac89375ea3b49e34e49006cc44a3f","2ff9995137f3e5d68971388ec58af0c79721626323884513f9f5e2e996ac1fdd","a7ac9fd7ac1c940b697ba3fed0fdf70d13cb31fab42e5aa49f72eaeb06df174c","991a1469a744cab4c7430a85229b3a616b24e3b2a0ca3fb1bf4491e8d44d5226","dbd4e3c1c81a350659f3ba09d931a953c37f6ea39d9e5880decfb22130fbbf70","c8d113d442ce7d757244e9ca2616396c5d9bd5076d3f14c66851d1561d34b943","49ecfc82833cce5065bf13363e7049baa284df8c7d4f141759d6910fc00d31cc","212355c1cc804424f1eae0d011a09d24cdb63b21f8cf0863ef197b6518919983","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"2f6c9750131d5d2fdaba85c164a930dc07d2d7e7e8970b89d32864aa6c72620c","affectsGlobalScope":true},"56d13f223ab40f71840795f5bef2552a397a70666ee60878222407f3893fb8d0",{"version":"aeeee3998c5a730f8689f04038d41cf4245c9edbf6ef29a698e45b36e399b8ed","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","90b94d3d2aa3432cc9dd2d15f56a38b166163fc555404c74243e1af29c5549d8","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","c993aac3b6d4a4620ef9651497069eb84806a131420e4f158ea9396fb8eb9b8c","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","e3b886bacdd1fbf1f72e654596c80a55c7bc1d10bdf464aaf52f45ecd243862f","d2f5c67858e65ebb932c2f4bd2af646f5764e8ad7f1e4fbe942a0b5ea05dc0e7","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","7f249c599e7a9335dd8e94a4bfe63f00e911756c3c23f77cdb6ef0ec4d479e4a",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"2cabc86ea4f972f2c8386903eccb8c19e2f2370fb9808b66dd8759c1f2ab30c7","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","945a841f9a591197154c85386bc5a1467d42d325104bb36db51bc566bbb240be","10c39ce1df102994b47d4bc0c71aa9a6aea76f4651a5ec51914431f50bc883a1",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","3fa48484c65913004d5abb5c0f917b61ea4684f32d05bb28c1ecfa5f05a9ed12","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"33eee034727baf564056b4ea719075c23d3b4767d0b5f9c6933b81f3d77774d2","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"127803f77e0dfee84b031b83ea7776875c6c4c89e11a81d00299ff58f163f0e2","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4",{"version":"dd9ea469d1bfaf589c6a196275d35cb1aa14014707c2c46d920c7b921e8f5bca","affectsGlobalScope":true},"badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1503a452a67127e5c2da794d1c7c44344d5038373aae16c9b03ac964db159edd","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":99,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96],[96,108,110],[96,104,105],[96,104,105,106,107],[96,109],[96,111],[53,96],[56,96],[57,62,96],[58,68,69,76,85,95,96],[58,59,68,76,96],[60,96],[61,62,69,77,96],[62,85,92,96],[63,65,68,76,96],[64,96],[65,66,96],[67,68,96],[68,96],[68,69,70,85,95,96],[68,69,70,85,96],[71,76,85,95,96],[68,69,71,72,76,85,92,95,96],[71,73,85,92,95,96],[53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102],[68,74,96],[75,95,96],[65,68,76,85,96],[77,96],[78,96],[56,79,96],[80,94,96,100],[81,96],[82,96],[68,83,96],[83,84,96,98],[68,85,86,87,96],[85,87,96],[85,86,96],[88,96],[89,96],[68,90,91,96],[90,91,96],[62,76,92,96],[93,96],[76,94,96],[57,71,82,95,96],[62,96],[85,96,97],[96,98],[96,99],[57,62,68,70,79,85,95,96,98,100],[85,96,101],[45,96],[45,46,47,96],[45,48,49,50,51,96],[46,96],[41,96],[41,42,43,44,96],[40,96],[40,41,96]],"referencedMap":[[46,1],[111,2],[104,1],[106,3],[108,4],[107,3],[105,1],[110,5],[109,1],[112,6],[53,7],[54,7],[56,8],[57,9],[58,10],[59,11],[60,12],[61,13],[62,14],[63,15],[64,16],[65,17],[66,17],[67,18],[68,19],[69,20],[70,21],[55,1],[102,1],[71,22],[72,23],[73,24],[103,25],[74,26],[75,27],[76,28],[77,29],[78,30],[79,31],[80,32],[81,33],[82,34],[83,35],[84,36],[85,37],[87,38],[86,39],[88,40],[89,41],[90,42],[91,43],[92,44],[93,45],[94,46],[95,47],[96,48],[97,49],[98,50],[99,51],[100,52],[101,53],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[49,54],[50,54],[51,54],[48,55],[52,56],[47,57],[43,1],[42,58],[40,1],[45,59],[41,60],[44,61]],"exportedModulesMap":[[46,1],[111,2],[104,1],[106,3],[108,4],[107,3],[105,1],[110,5],[109,1],[112,6],[53,7],[54,7],[56,8],[57,9],[58,10],[59,11],[60,12],[61,13],[62,14],[63,15],[64,16],[65,17],[66,17],[67,18],[68,19],[69,20],[70,21],[55,1],[102,1],[71,22],[72,23],[73,24],[103,25],[74,26],[75,27],[76,28],[77,29],[78,30],[79,31],[80,32],[81,33],[82,34],[83,35],[84,36],[85,37],[87,38],[86,39],[88,40],[89,41],[90,42],[91,43],[92,44],[93,45],[94,46],[95,47],[96,48],[97,49],[98,50],[99,51],[100,52],[101,53],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[49,54],[50,54],[51,54],[48,55],[52,56],[47,57],[43,1],[42,58],[40,1],[45,59],[41,60],[44,61]],"semanticDiagnosticsPerFile":[46,111,104,106,108,107,105,110,109,112,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,55,102,71,72,73,103,74,75,76,77,78,79,80,81,82,83,84,85,87,86,88,89,90,91,92,93,94,95,96,97,98,99,100,101,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,49,50,51,48,52,47,43,42,40,45,41,44]},"version":"4.6.2"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as types from '@babel/types';
|
|
2
|
+
export declare const generateResponseWithStatus: (status: number, revalidationStatus: boolean) => types.ReturnStatement;
|
|
3
|
+
export declare const appendDataToObjectExpression: (expression: string) => string;
|
|
4
|
+
export declare const generateCallbackExpression: (routeMappings: Record<string, string[]>) => types.ArrowFunctionExpression;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,eAAO,MAAM,0BAA0B,WAC7B,MAAM,sBACM,OAAO,KAC1B,MAAM,eAoBR,CAAA;AAED,eAAO,MAAM,4BAA4B,eAAgB,MAAM,KAAG,MAIjE,CAAA;AAED,eAAO,MAAM,0BAA0B,kBACtB,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,KACtC,MAAM,uBAyCR,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import * as types from '@babel/types';
|
|
11
|
+
export var generateResponseWithStatus = function (status, revalidationStatus) {
|
|
12
|
+
return types.returnStatement(types.callExpression(types.memberExpression(types.callExpression(types.memberExpression(types.identifier('res'), types.identifier('status')), [types.numericLiteral(status)]), types.identifier('json')), [
|
|
13
|
+
types.objectExpression([
|
|
14
|
+
types.objectProperty(types.identifier('revalidated'), types.booleanLiteral(revalidationStatus)),
|
|
15
|
+
]),
|
|
16
|
+
]));
|
|
17
|
+
};
|
|
18
|
+
export var appendDataToObjectExpression = function (expression) {
|
|
19
|
+
var regex = /\${(.*?)}/g;
|
|
20
|
+
var result = expression.replace(regex, function (_, p1) { return "${data.".concat(p1, "}"); });
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
export var generateCallbackExpression = function (routeMappings) {
|
|
24
|
+
var switchCases = Object.entries(routeMappings).map(function (_a) {
|
|
25
|
+
var contentType = _a[0], paths = _a[1];
|
|
26
|
+
return types.switchCase(types.stringLiteral(contentType), __spreadArray(__spreadArray([], paths.map(function (dynamicPath) {
|
|
27
|
+
return types.expressionStatement(types.callExpression(types.memberExpression(types.identifier('res'), types.identifier('revalidate')), [
|
|
28
|
+
types.templateLiteral([
|
|
29
|
+
types.templateElement({
|
|
30
|
+
raw: appendDataToObjectExpression(dynamicPath),
|
|
31
|
+
cooked: appendDataToObjectExpression(dynamicPath),
|
|
32
|
+
}),
|
|
33
|
+
], []),
|
|
34
|
+
]));
|
|
35
|
+
}), true), [
|
|
36
|
+
types.breakStatement(),
|
|
37
|
+
], false));
|
|
38
|
+
});
|
|
39
|
+
switchCases.push(types.switchCase(null, [
|
|
40
|
+
types.throwStatement(types.newExpression(types.identifier('Error'), [
|
|
41
|
+
types.stringLiteral('Invalid content type'),
|
|
42
|
+
])),
|
|
43
|
+
]));
|
|
44
|
+
return types.arrowFunctionExpression([types.identifier('data'), types.identifier('contentType')], types.blockStatement([types.switchStatement(types.identifier('contentType'), switchCases)]));
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,MAAM,CAAC,IAAM,0BAA0B,GAAG,UACxC,MAAc,EACd,kBAA2B;IAE3B,OAAO,KAAK,CAAC,eAAe,CAC1B,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CACpB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAC3E,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAC/B,EACD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CACzB,EACD;QACE,KAAK,CAAC,gBAAgB,CAAC;YACrB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAC/B,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CACzC;SACF,CAAC;KACH,CACF,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,4BAA4B,GAAG,UAAC,UAAkB;IAC7D,IAAM,KAAK,GAAG,YAAY,CAAA;IAC1B,IAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,UAAC,CAAC,EAAE,EAAE,IAAK,OAAA,iBAAW,EAAE,MAAG,EAAhB,CAAgB,CAAC,CAAA;IACrE,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,0BAA0B,GAAG,UACxC,aAAuC;IAEvC,IAAM,WAAW,GAAuB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CACvE,UAAC,EAAoB;YAAnB,WAAW,QAAA,EAAE,KAAK,QAAA;QAClB,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,kCACnD,KAAK,CAAC,GAAG,CAAC,UAAC,WAAW;YACvB,OAAO,KAAK,CAAC,mBAAmB,CAC9B,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAC/E;gBACE,KAAK,CAAC,eAAe,CACnB;oBACE,KAAK,CAAC,eAAe,CAAC;wBACpB,GAAG,EAAE,4BAA4B,CAAC,WAAW,CAAC;wBAC9C,MAAM,EAAE,4BAA4B,CAAC,WAAW,CAAC;qBAClD,CAAC;iBACH,EACD,EAAE,CACH;aACF,CACF,CACF,CAAA;QACH,CAAC,CAAC;YACF,KAAK,CAAC,cAAc,EAAE;kBACtB,CAAA;IACJ,CAAC,CACF,CAAA;IAED,WAAW,CAAC,IAAI,CACd,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE;QACrB,KAAK,CAAC,cAAc,CAClB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC7C,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC;SAC5C,CAAC,CACH;KACF,CAAC,CACH,CAAA;IAED,OAAO,KAAK,CAAC,uBAAuB,CAClC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC3D,KAAK,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAC5F,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teleporthq/teleport-next-revalidate-api",
|
|
3
|
+
"version": "0.30.0-alpha.0",
|
|
4
|
+
"description": "A plugin for handling cache and enabling on demand revalidation in NextJS.",
|
|
5
|
+
"author": "teleportHQ",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://teleporthq.io/",
|
|
8
|
+
"main": "dist/cjs/index.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/cjs/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+ssh://git@github.com/teleporthq/teleport-code-generators.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/teleporthq/teleport-code-generators/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rimraf dist",
|
|
24
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@babel/types": "^7.5.5",
|
|
28
|
+
"@teleporthq/teleport-component-generator": "^0.31.0-alpha.0",
|
|
29
|
+
"@teleporthq/teleport-plugin-import-statements": "^0.31.0-alpha.0",
|
|
30
|
+
"@teleporthq/teleport-postprocessor-prettier-js": "^0.31.0-alpha.0",
|
|
31
|
+
"@teleporthq/teleport-types": "^0.31.0-alpha.0"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "e9d3455b100f69e94394f9aa7a601fb8a0e2ce21"
|
|
34
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChunkType,
|
|
3
|
+
ComponentPlugin,
|
|
4
|
+
ComponentPluginFactory,
|
|
5
|
+
FileType,
|
|
6
|
+
ProjectUIDL,
|
|
7
|
+
} from '@teleporthq/teleport-types'
|
|
8
|
+
import * as types from '@babel/types'
|
|
9
|
+
import { generateCallbackExpression, generateResponseWithStatus } from './utils'
|
|
10
|
+
|
|
11
|
+
interface NextCacheValidationProps {
|
|
12
|
+
routeMappers: Record<string, string[]>
|
|
13
|
+
webhook: ProjectUIDL['resources']['cache']['webhook']
|
|
14
|
+
cacheHandlerSecret?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const createNextCacheValidationPlugin: ComponentPluginFactory<NextCacheValidationProps> = (
|
|
18
|
+
config
|
|
19
|
+
) => {
|
|
20
|
+
const { webhook, routeMappers = {}, cacheHandlerSecret } = config
|
|
21
|
+
|
|
22
|
+
const cacheValidationPlugin: ComponentPlugin = async (structure) => {
|
|
23
|
+
const { dependencies, chunks } = structure
|
|
24
|
+
|
|
25
|
+
const webhookHandlerContent: types.Statement[] = [
|
|
26
|
+
types.expressionStatement(
|
|
27
|
+
types.awaitExpression(
|
|
28
|
+
types.callExpression(types.identifier(webhook.name), [
|
|
29
|
+
types.identifier('req'),
|
|
30
|
+
generateCallbackExpression(routeMappers),
|
|
31
|
+
])
|
|
32
|
+
)
|
|
33
|
+
),
|
|
34
|
+
generateResponseWithStatus(200, true),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
if (cacheHandlerSecret) {
|
|
38
|
+
webhookHandlerContent.unshift(
|
|
39
|
+
types.ifStatement(
|
|
40
|
+
types.binaryExpression(
|
|
41
|
+
'!==',
|
|
42
|
+
types.memberExpression(
|
|
43
|
+
types.memberExpression(
|
|
44
|
+
types.identifier('process'),
|
|
45
|
+
types.identifier('env'),
|
|
46
|
+
false,
|
|
47
|
+
true
|
|
48
|
+
),
|
|
49
|
+
types.identifier(cacheHandlerSecret),
|
|
50
|
+
false
|
|
51
|
+
),
|
|
52
|
+
types.memberExpression(
|
|
53
|
+
types.memberExpression(types.identifier('req'), types.identifier('query')),
|
|
54
|
+
types.stringLiteral(cacheHandlerSecret),
|
|
55
|
+
true,
|
|
56
|
+
true
|
|
57
|
+
)
|
|
58
|
+
),
|
|
59
|
+
types.blockStatement([generateResponseWithStatus(401, false)])
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const componentChunkContent = types.exportDefaultDeclaration(
|
|
65
|
+
types.functionDeclaration(
|
|
66
|
+
types.identifier('handler'),
|
|
67
|
+
[types.identifier('req'), types.identifier('res')],
|
|
68
|
+
types.blockStatement([
|
|
69
|
+
types.tryStatement(
|
|
70
|
+
types.blockStatement(webhookHandlerContent),
|
|
71
|
+
types.catchClause(
|
|
72
|
+
types.identifier('error'),
|
|
73
|
+
types.blockStatement([
|
|
74
|
+
types.expressionStatement(
|
|
75
|
+
types.callExpression(
|
|
76
|
+
types.memberExpression(types.identifier('console'), types.identifier('log')),
|
|
77
|
+
[types.identifier('error')]
|
|
78
|
+
)
|
|
79
|
+
),
|
|
80
|
+
generateResponseWithStatus(500, false),
|
|
81
|
+
])
|
|
82
|
+
)
|
|
83
|
+
),
|
|
84
|
+
]),
|
|
85
|
+
false,
|
|
86
|
+
true
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
chunks.push({
|
|
91
|
+
name: 'revalidateChunk',
|
|
92
|
+
type: ChunkType.AST,
|
|
93
|
+
fileType: FileType.JS,
|
|
94
|
+
content: componentChunkContent,
|
|
95
|
+
linkAfter: ['import-local', 'import-lib', 'import-pack'],
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
dependencies[webhook.name] = webhook.dependency
|
|
99
|
+
|
|
100
|
+
return structure
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return cacheValidationPlugin
|
|
104
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ProjectPlugin, ProjectPluginStructure } from '@teleporthq/teleport-types'
|
|
2
|
+
import { createComponentGenerator } from '@teleporthq/teleport-component-generator'
|
|
3
|
+
import { createNextCacheValidationPlugin } from './component-plugin'
|
|
4
|
+
import importStatementsPlugin from '@teleporthq/teleport-plugin-import-statements'
|
|
5
|
+
import prettierJSPlugin from '@teleporthq/teleport-postprocessor-prettier-js'
|
|
6
|
+
|
|
7
|
+
export class ProjectPluginRevalidateAPI implements ProjectPlugin {
|
|
8
|
+
private routeMappers: Record<string, string[]> = {}
|
|
9
|
+
private cacheHandlerPath: string[] = ['pages', 'api']
|
|
10
|
+
private cacheHandlerSecret: string | null = null
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
params: {
|
|
14
|
+
routeMappers?: Record<string, string[]>
|
|
15
|
+
cacheHandlerPath?: string[]
|
|
16
|
+
cacheHandlerSecret?: string
|
|
17
|
+
} = {}
|
|
18
|
+
) {
|
|
19
|
+
const { routeMappers, cacheHandlerPath, cacheHandlerSecret } = params
|
|
20
|
+
if (routeMappers) {
|
|
21
|
+
this.routeMappers = routeMappers
|
|
22
|
+
}
|
|
23
|
+
if (cacheHandlerPath) {
|
|
24
|
+
this.cacheHandlerPath = cacheHandlerPath
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (cacheHandlerSecret) {
|
|
28
|
+
this.cacheHandlerSecret = cacheHandlerSecret
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async runAfter(structure: ProjectPluginStructure) {
|
|
33
|
+
const { uidl, files } = structure
|
|
34
|
+
if (!uidl.resources.cache?.webhook?.dependency) {
|
|
35
|
+
return structure
|
|
36
|
+
}
|
|
37
|
+
const generator = createComponentGenerator()
|
|
38
|
+
generator.addPlugin(
|
|
39
|
+
createNextCacheValidationPlugin({
|
|
40
|
+
routeMappers: this.routeMappers,
|
|
41
|
+
cacheHandlerSecret: this.cacheHandlerSecret,
|
|
42
|
+
webhook: uidl.resources.cache.webhook,
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
generator.addPlugin(importStatementsPlugin)
|
|
46
|
+
generator.addPostProcessor(prettierJSPlugin)
|
|
47
|
+
|
|
48
|
+
const { files: cacheHandlerFiles, dependencies: cacheHandlerDependencies } =
|
|
49
|
+
await generator.generateComponent(
|
|
50
|
+
{
|
|
51
|
+
...uidl.root,
|
|
52
|
+
name: 'revalidate',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
skipValidation: true,
|
|
56
|
+
skipNavlinkResolver: true,
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
structure.dependencies = { ...structure.dependencies, ...cacheHandlerDependencies }
|
|
61
|
+
|
|
62
|
+
files.set('revalidate', {
|
|
63
|
+
path: this.cacheHandlerPath,
|
|
64
|
+
files: cacheHandlerFiles,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return structure
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async runBefore(structure: ProjectPluginStructure) {
|
|
71
|
+
return structure
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as types from '@babel/types'
|
|
2
|
+
|
|
3
|
+
export const generateResponseWithStatus = (
|
|
4
|
+
status: number,
|
|
5
|
+
revalidationStatus: boolean
|
|
6
|
+
): types.ReturnStatement => {
|
|
7
|
+
return types.returnStatement(
|
|
8
|
+
types.callExpression(
|
|
9
|
+
types.memberExpression(
|
|
10
|
+
types.callExpression(
|
|
11
|
+
types.memberExpression(types.identifier('res'), types.identifier('status')),
|
|
12
|
+
[types.numericLiteral(status)]
|
|
13
|
+
),
|
|
14
|
+
types.identifier('json')
|
|
15
|
+
),
|
|
16
|
+
[
|
|
17
|
+
types.objectExpression([
|
|
18
|
+
types.objectProperty(
|
|
19
|
+
types.identifier('revalidated'),
|
|
20
|
+
types.booleanLiteral(revalidationStatus)
|
|
21
|
+
),
|
|
22
|
+
]),
|
|
23
|
+
]
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const appendDataToObjectExpression = (expression: string): string => {
|
|
29
|
+
const regex = /\${(.*?)}/g
|
|
30
|
+
const result = expression.replace(regex, (_, p1) => `\${data.${p1}}`)
|
|
31
|
+
return result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const generateCallbackExpression = (
|
|
35
|
+
routeMappings: Record<string, string[]>
|
|
36
|
+
): types.ArrowFunctionExpression => {
|
|
37
|
+
const switchCases: types.SwitchCase[] = Object.entries(routeMappings).map(
|
|
38
|
+
([contentType, paths]) => {
|
|
39
|
+
return types.switchCase(types.stringLiteral(contentType), [
|
|
40
|
+
...paths.map((dynamicPath) => {
|
|
41
|
+
return types.expressionStatement(
|
|
42
|
+
types.callExpression(
|
|
43
|
+
types.memberExpression(types.identifier('res'), types.identifier('revalidate')),
|
|
44
|
+
[
|
|
45
|
+
types.templateLiteral(
|
|
46
|
+
[
|
|
47
|
+
types.templateElement({
|
|
48
|
+
raw: appendDataToObjectExpression(dynamicPath),
|
|
49
|
+
cooked: appendDataToObjectExpression(dynamicPath),
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
[]
|
|
53
|
+
),
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
}),
|
|
58
|
+
types.breakStatement(),
|
|
59
|
+
])
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
switchCases.push(
|
|
64
|
+
types.switchCase(null, [
|
|
65
|
+
types.throwStatement(
|
|
66
|
+
types.newExpression(types.identifier('Error'), [
|
|
67
|
+
types.stringLiteral('Invalid content type'),
|
|
68
|
+
])
|
|
69
|
+
),
|
|
70
|
+
])
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
return types.arrowFunctionExpression(
|
|
74
|
+
[types.identifier('data'), types.identifier('contentType')],
|
|
75
|
+
types.blockStatement([types.switchStatement(types.identifier('contentType'), switchCases)])
|
|
76
|
+
)
|
|
77
|
+
}
|