pingram 1.0.11-alpha.1165 → 1.0.11-alpha.1166
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/package.json +1 -1
- package/dist/generate-client.d.ts +0 -1
- package/dist/generate-client.js +0 -164
- package/dist/package.json +0 -70
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/generate-client.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const package_json_1 = __importDefault(require("./package.json"));
|
|
42
|
-
const jsyaml = __importStar(require("js-yaml"));
|
|
43
|
-
const Mustache = __importStar(require("mustache"));
|
|
44
|
-
/**
|
|
45
|
-
* Convert string to camelCase (e.g., "Account" -> "account")
|
|
46
|
-
*/
|
|
47
|
-
function toCamelCase(str) {
|
|
48
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Convert string to PascalCase (e.g., "account" -> "Account")
|
|
52
|
-
*/
|
|
53
|
-
function toPascalCase(str) {
|
|
54
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Extract API tags from OpenAPI spec
|
|
58
|
-
* Tags determine how operations are grouped (e.g., "Users", "Logs")
|
|
59
|
-
*/
|
|
60
|
-
function extractApisFromOpenAPI(openapiPath) {
|
|
61
|
-
/* eslint-disable-next-line */
|
|
62
|
-
const content = fs.readFileSync(openapiPath, 'utf-8');
|
|
63
|
-
const spec = jsyaml.load(content);
|
|
64
|
-
// Collect all unique tags from spec.tags and operations
|
|
65
|
-
const tagSet = new Set();
|
|
66
|
-
if (spec.tags) {
|
|
67
|
-
spec.tags.forEach((tag) => tagSet.add(tag.name));
|
|
68
|
-
}
|
|
69
|
-
if (spec.paths) {
|
|
70
|
-
Object.values(spec.paths).forEach((pathItem) => {
|
|
71
|
-
if (!pathItem)
|
|
72
|
-
return;
|
|
73
|
-
const operations = [
|
|
74
|
-
pathItem.get,
|
|
75
|
-
pathItem.put,
|
|
76
|
-
pathItem.post,
|
|
77
|
-
pathItem.delete,
|
|
78
|
-
pathItem.options,
|
|
79
|
-
pathItem.head,
|
|
80
|
-
pathItem.patch,
|
|
81
|
-
pathItem.trace
|
|
82
|
-
];
|
|
83
|
-
operations.forEach((operation) => {
|
|
84
|
-
if (operation?.tags) {
|
|
85
|
-
operation.tags.forEach((tag) => tagSet.add(tag));
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// Convert tags to structured API info with proper naming
|
|
91
|
-
return Array.from(tagSet)
|
|
92
|
-
.sort()
|
|
93
|
-
.map((tag) => ({
|
|
94
|
-
name: tag,
|
|
95
|
-
className: `${toPascalCase(tag)}Api`, // e.g., "UsersApi"
|
|
96
|
-
propertyName: toCamelCase(tag)
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Extract operations without tags (top-level methods like client.send())
|
|
101
|
-
*/
|
|
102
|
-
function extractTopLevelOperations(openapiPath) {
|
|
103
|
-
/* eslint-disable-next-line */
|
|
104
|
-
const content = fs.readFileSync(openapiPath, 'utf-8');
|
|
105
|
-
const spec = jsyaml.load(content);
|
|
106
|
-
const topLevelOps = [];
|
|
107
|
-
if (spec.paths) {
|
|
108
|
-
Object.values(spec.paths).forEach((pathItem) => {
|
|
109
|
-
if (!pathItem)
|
|
110
|
-
return;
|
|
111
|
-
const operations = [
|
|
112
|
-
pathItem.get,
|
|
113
|
-
pathItem.put,
|
|
114
|
-
pathItem.post,
|
|
115
|
-
pathItem.delete,
|
|
116
|
-
pathItem.options,
|
|
117
|
-
pathItem.head,
|
|
118
|
-
pathItem.patch,
|
|
119
|
-
pathItem.trace
|
|
120
|
-
];
|
|
121
|
-
operations.forEach((operation) => {
|
|
122
|
-
// Operations with no tags become top-level methods
|
|
123
|
-
if (operation?.operationId &&
|
|
124
|
-
(!operation.tags || operation.tags.length === 0)) {
|
|
125
|
-
topLevelOps.push({ operationId: operation.operationId });
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return topLevelOps;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Generate Pingram wrapper from OpenAPI spec
|
|
134
|
-
*
|
|
135
|
-
* This script:
|
|
136
|
-
* 1. Parses the OpenAPI spec to extract API groupings
|
|
137
|
-
* 2. Transforms tag names into proper TypeScript naming (camelCase/PascalCase)
|
|
138
|
-
* 3. Renders the Mustache template with structured data
|
|
139
|
-
* 4. Formats the output with Prettier
|
|
140
|
-
*/
|
|
141
|
-
async function generateClient() {
|
|
142
|
-
const sdkDir = __dirname;
|
|
143
|
-
const openapiPath = path.join(sdkDir, '../../codegen/openapi.yaml');
|
|
144
|
-
const templatePath = path.join(sdkDir, 'templates/client-wrapper.mustache');
|
|
145
|
-
const outputPath = path.join(sdkDir, 'src/client.ts');
|
|
146
|
-
// Extract and transform API metadata from OpenAPI spec
|
|
147
|
-
const apis = extractApisFromOpenAPI(openapiPath);
|
|
148
|
-
const topLevelOps = extractTopLevelOperations(openapiPath);
|
|
149
|
-
// Prepare template data with all APIs and top-level methods
|
|
150
|
-
const templateData = {
|
|
151
|
-
apis,
|
|
152
|
-
hasDefaultApi: topLevelOps.length > 0,
|
|
153
|
-
topLevelOperations: topLevelOps,
|
|
154
|
-
version: package_json_1.default.version
|
|
155
|
-
};
|
|
156
|
-
// Render Mustache template and write output
|
|
157
|
-
/* eslint-disable-next-line */
|
|
158
|
-
const templateContent = fs.readFileSync(templatePath, 'utf-8');
|
|
159
|
-
const clientCode = Mustache.render(templateContent, templateData);
|
|
160
|
-
/* eslint-disable-next-line */
|
|
161
|
-
fs.writeFileSync(outputPath, clientCode);
|
|
162
|
-
// Note: Prettier formatting is handled by the parent generate.ts script
|
|
163
|
-
}
|
|
164
|
-
generateClient();
|
package/dist/package.json
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pingram",
|
|
3
|
-
"version": "1.0.11-alpha.1165",
|
|
4
|
-
"description": "Official Node.js SDK for Pingram - Send notifications via Email, SMS, Push, In-App, and more",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"default": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./webhooks": {
|
|
14
|
-
"types": "./dist/src/webhooks.d.ts",
|
|
15
|
-
"default": "./dist/src/webhooks.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"clean": "rm -rf dist",
|
|
21
|
-
"prepublishOnly": "npm run build"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"pingram",
|
|
25
|
-
"notificationapi",
|
|
26
|
-
"notification",
|
|
27
|
-
"sdk",
|
|
28
|
-
"typescript",
|
|
29
|
-
"email",
|
|
30
|
-
"sms",
|
|
31
|
-
"push",
|
|
32
|
-
"in-app",
|
|
33
|
-
"slack",
|
|
34
|
-
"api"
|
|
35
|
-
],
|
|
36
|
-
"author": "Pingram",
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/notificationapi-com/serverless.git",
|
|
41
|
-
"directory": "sdks/node"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://www.pingram.io/docs/reference/node",
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@openapitools/openapi-generator-cli": "^2.25.2",
|
|
46
|
-
"@types/js-yaml": "^3.12.5",
|
|
47
|
-
"@types/mustache": "^4.2.5",
|
|
48
|
-
"@types/node": "^20.11.30",
|
|
49
|
-
"js-yaml": "^3.14.2",
|
|
50
|
-
"mustache": "^4.2.0",
|
|
51
|
-
"openapi-types": "^12.1.0",
|
|
52
|
-
"prettier": "^3.2.5",
|
|
53
|
-
"ts-node": "^10.9.2",
|
|
54
|
-
"typescript": "^5.4.3"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"node-fetch": "^2.7.0"
|
|
58
|
-
},
|
|
59
|
-
"overrides": {
|
|
60
|
-
"minimatch": ">=10.2.3"
|
|
61
|
-
},
|
|
62
|
-
"files": [
|
|
63
|
-
"dist/**/*",
|
|
64
|
-
"README.md",
|
|
65
|
-
"package.json"
|
|
66
|
-
],
|
|
67
|
-
"publishConfig": {
|
|
68
|
-
"access": "public"
|
|
69
|
-
}
|
|
70
|
-
}
|