@jutsustack/api-codegen 0.0.0-stage → 0.1.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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +331 -2
  3. package/bin/jutsu-api.js +14 -0
  4. package/dist/cache/manifest.d.ts +36 -0
  5. package/dist/cache/manifest.d.ts.map +1 -0
  6. package/dist/cache/manifest.js +37 -0
  7. package/dist/cache/manifest.js.map +1 -0
  8. package/dist/cli.d.ts +7 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +208 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/codegen/emit-api.d.ts +5 -0
  13. package/dist/codegen/emit-api.d.ts.map +1 -0
  14. package/dist/codegen/emit-api.js +80 -0
  15. package/dist/codegen/emit-api.js.map +1 -0
  16. package/dist/codegen/emit-hooks.d.ts +5 -0
  17. package/dist/codegen/emit-hooks.d.ts.map +1 -0
  18. package/dist/codegen/emit-hooks.js +67 -0
  19. package/dist/codegen/emit-hooks.js.map +1 -0
  20. package/dist/codegen/emit-types.d.ts +4 -0
  21. package/dist/codegen/emit-types.d.ts.map +1 -0
  22. package/dist/codegen/emit-types.js +228 -0
  23. package/dist/codegen/emit-types.js.map +1 -0
  24. package/dist/codegen/emit.d.ts +20 -0
  25. package/dist/codegen/emit.d.ts.map +1 -0
  26. package/dist/codegen/emit.js +72 -0
  27. package/dist/codegen/emit.js.map +1 -0
  28. package/dist/codegen/files.d.ts +24 -0
  29. package/dist/codegen/files.d.ts.map +1 -0
  30. package/dist/codegen/files.js +66 -0
  31. package/dist/codegen/files.js.map +1 -0
  32. package/dist/codegen/plan.d.ts +33 -0
  33. package/dist/codegen/plan.d.ts.map +1 -0
  34. package/dist/codegen/plan.js +79 -0
  35. package/dist/codegen/plan.js.map +1 -0
  36. package/dist/codegen/print.d.ts +14 -0
  37. package/dist/codegen/print.d.ts.map +1 -0
  38. package/dist/codegen/print.js +62 -0
  39. package/dist/codegen/print.js.map +1 -0
  40. package/dist/codegen/templates/hooks.d.ts +11 -0
  41. package/dist/codegen/templates/hooks.d.ts.map +1 -0
  42. package/dist/codegen/templates/hooks.js +272 -0
  43. package/dist/codegen/templates/hooks.js.map +1 -0
  44. package/dist/codegen/templates/runtime.d.ts +2 -0
  45. package/dist/codegen/templates/runtime.d.ts.map +1 -0
  46. package/dist/codegen/templates/runtime.js +485 -0
  47. package/dist/codegen/templates/runtime.js.map +1 -0
  48. package/dist/codegen/tsType.d.ts +16 -0
  49. package/dist/codegen/tsType.d.ts.map +1 -0
  50. package/dist/codegen/tsType.js +111 -0
  51. package/dist/codegen/tsType.js.map +1 -0
  52. package/dist/collect/collect.d.ts +27 -0
  53. package/dist/collect/collect.d.ts.map +1 -0
  54. package/dist/collect/collect.js +476 -0
  55. package/dist/collect/collect.js.map +1 -0
  56. package/dist/collect/naming.d.ts +29 -0
  57. package/dist/collect/naming.d.ts.map +1 -0
  58. package/dist/collect/naming.js +140 -0
  59. package/dist/collect/naming.js.map +1 -0
  60. package/dist/collect/path.d.ts +18 -0
  61. package/dist/collect/path.d.ts.map +1 -0
  62. package/dist/collect/path.js +69 -0
  63. package/dist/collect/path.js.map +1 -0
  64. package/dist/config/init.d.ts +29 -0
  65. package/dist/config/init.d.ts.map +1 -0
  66. package/dist/config/init.js +86 -0
  67. package/dist/config/init.js.map +1 -0
  68. package/dist/config/load.d.ts +12 -0
  69. package/dist/config/load.d.ts.map +1 -0
  70. package/dist/config/load.js +87 -0
  71. package/dist/config/load.js.map +1 -0
  72. package/dist/config/types.d.ts +81 -0
  73. package/dist/config/types.d.ts.map +1 -0
  74. package/dist/config/types.js +2 -0
  75. package/dist/config/types.js.map +1 -0
  76. package/dist/config/validate.d.ts +13 -0
  77. package/dist/config/validate.d.ts.map +1 -0
  78. package/dist/config/validate.js +185 -0
  79. package/dist/config/validate.js.map +1 -0
  80. package/dist/generate.d.ts +62 -0
  81. package/dist/generate.d.ts.map +1 -0
  82. package/dist/generate.js +254 -0
  83. package/dist/generate.js.map +1 -0
  84. package/dist/index.d.ts +24 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +15 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/model/collection.d.ts +84 -0
  89. package/dist/model/collection.d.ts.map +1 -0
  90. package/dist/model/collection.js +13 -0
  91. package/dist/model/collection.js.map +1 -0
  92. package/dist/model/infer.d.ts +15 -0
  93. package/dist/model/infer.d.ts.map +1 -0
  94. package/dist/model/infer.js +98 -0
  95. package/dist/model/infer.js.map +1 -0
  96. package/dist/model/merge.d.ts +8 -0
  97. package/dist/model/merge.d.ts.map +1 -0
  98. package/dist/model/merge.js +133 -0
  99. package/dist/model/merge.js.map +1 -0
  100. package/dist/model/reserved.d.ts +6 -0
  101. package/dist/model/reserved.d.ts.map +1 -0
  102. package/dist/model/reserved.js +67 -0
  103. package/dist/model/reserved.js.map +1 -0
  104. package/dist/model/schema.d.ts +58 -0
  105. package/dist/model/schema.d.ts.map +1 -0
  106. package/dist/model/schema.js +2 -0
  107. package/dist/model/schema.js.map +1 -0
  108. package/dist/parsers/openapi-schema.d.ts +35 -0
  109. package/dist/parsers/openapi-schema.d.ts.map +1 -0
  110. package/dist/parsers/openapi-schema.js +241 -0
  111. package/dist/parsers/openapi-schema.js.map +1 -0
  112. package/dist/parsers/openapi.d.ts +9 -0
  113. package/dist/parsers/openapi.d.ts.map +1 -0
  114. package/dist/parsers/openapi.js +432 -0
  115. package/dist/parsers/openapi.js.map +1 -0
  116. package/dist/parsers/postman.d.ts +24 -0
  117. package/dist/parsers/postman.d.ts.map +1 -0
  118. package/dist/parsers/postman.js +491 -0
  119. package/dist/parsers/postman.js.map +1 -0
  120. package/dist/parsers/types.d.ts +53 -0
  121. package/dist/parsers/types.d.ts.map +1 -0
  122. package/dist/parsers/types.js +2 -0
  123. package/dist/parsers/types.js.map +1 -0
  124. package/dist/sources/load.d.ts +32 -0
  125. package/dist/sources/load.d.ts.map +1 -0
  126. package/dist/sources/load.js +294 -0
  127. package/dist/sources/load.js.map +1 -0
  128. package/dist/sources/parse.d.ts +7 -0
  129. package/dist/sources/parse.d.ts.map +1 -0
  130. package/dist/sources/parse.js +48 -0
  131. package/dist/sources/parse.js.map +1 -0
  132. package/dist/util/errors.d.ts +10 -0
  133. package/dist/util/errors.d.ts.map +1 -0
  134. package/dist/util/errors.js +18 -0
  135. package/dist/util/errors.js.map +1 -0
  136. package/dist/util/fs.d.ts +8 -0
  137. package/dist/util/fs.d.ts.map +1 -0
  138. package/dist/util/fs.js +36 -0
  139. package/dist/util/fs.js.map +1 -0
  140. package/dist/util/hash.d.ts +4 -0
  141. package/dist/util/hash.d.ts.map +1 -0
  142. package/dist/util/hash.js +23 -0
  143. package/dist/util/hash.js.map +1 -0
  144. package/dist/util/json.d.ts +11 -0
  145. package/dist/util/json.d.ts.map +1 -0
  146. package/dist/util/json.js +24 -0
  147. package/dist/util/json.js.map +1 -0
  148. package/dist/util/log.d.ts +23 -0
  149. package/dist/util/log.d.ts.map +1 -0
  150. package/dist/util/log.js +42 -0
  151. package/dist/util/log.js.map +1 -0
  152. package/dist/version.d.ts +3 -0
  153. package/dist/version.d.ts.map +1 -0
  154. package/dist/version.js +4 -0
  155. package/dist/version.js.map +1 -0
  156. package/package.json +89 -4
  157. package/schema/config.schema.json +136 -0
@@ -0,0 +1,3 @@
1
+ export declare const PACKAGE_NAME = "@jutsustack/api-codegen";
2
+ export declare const VERSION = "0.1.0";
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,4BAA4B,CAAC;AACtD,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Kept in sync with package.json by test/version.test.ts.
2
+ export const PACKAGE_NAME = '@jutsustack/api-codegen';
3
+ export const VERSION = '0.1.0';
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AACtD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,91 @@
1
1
  {
2
2
  "name": "@jutsustack/api-codegen",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Generate a typed API layer for React Native, React and Next.js from Postman, Swagger and OpenAPI collections",
5
+ "keywords": [
6
+ "codegen",
7
+ "openapi",
8
+ "swagger",
9
+ "postman",
10
+ "react-native",
11
+ "react",
12
+ "nextjs",
13
+ "typescript",
14
+ "api-client",
15
+ "jutsustack"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "JutsuStack <joshijignesh50@gmail.com> (https://github.com/jutsustack)",
19
+ "homepage": "https://github.com/JutsuStack/api-codegen#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/JutsuStack/api-codegen.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/JutsuStack/api-codegen/issues"
26
+ },
27
+ "type": "module",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./schema.json": "./schema/config.schema.json",
36
+ "./package.json": "./package.json"
37
+ },
38
+ "bin": {
39
+ "jutsu-api": "bin/jutsu-api.js"
40
+ },
41
+ "files": [
42
+ "bin",
43
+ "dist",
44
+ "schema",
45
+ "!**/*.tsbuildinfo"
46
+ ],
47
+ "engines": {
48
+ "node": ">=18.18"
49
+ },
50
+ "sideEffects": false,
51
+ "scripts": {
52
+ "build": "del-cli dist && tsc -p tsconfig.build.json",
53
+ "typecheck": "tsc -p tsconfig.json && tsc -p test/tsconfig.json",
54
+ "lint": "eslint .",
55
+ "format": "prettier --write .",
56
+ "format:check": "prettier --check .",
57
+ "test": "jest",
58
+ "verify": "yarn lint && yarn typecheck && yarn test --ci && yarn build && node scripts/smoke.mjs",
59
+ "prepack": "yarn build"
60
+ },
61
+ "dependencies": {
62
+ "yaml": "^2.9.1"
63
+ },
64
+ "devDependencies": {
65
+ "@babel/core": "^7.29.7",
66
+ "@babel/preset-env": "^7.29.7",
67
+ "@babel/preset-typescript": "^7.29.7",
68
+ "@eslint/js": "^9.39.5",
69
+ "@types/jest": "^30.0.0",
70
+ "@types/node": "^20.19.0",
71
+ "@types/react": "^19.2.0",
72
+ "babel-jest": "^30.5.2",
73
+ "del-cli": "^6.0.0",
74
+ "eslint": "^9.39.5",
75
+ "jest": "^30.5.2",
76
+ "prettier": "^3.9.6",
77
+ "typescript": "~6.0.3",
78
+ "typescript-eslint": "^8.72.0"
79
+ },
80
+ "packageManager": "yarn@4.11.0",
81
+ "publishConfig": {
82
+ "access": "public"
83
+ },
84
+ "prettier": {
85
+ "quoteProps": "consistent",
86
+ "singleQuote": true,
87
+ "tabWidth": 2,
88
+ "trailingComma": "es5",
89
+ "useTabs": false
90
+ }
91
+ }
@@ -0,0 +1,136 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/JutsuStack/api-codegen/schema/config.schema.json",
4
+ "title": "@jutsustack/api-codegen config (<project>-api.config.json)",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["project", "target", "output", "sources"],
8
+ "properties": {
9
+ "$schema": { "type": "string" },
10
+ "project": {
11
+ "type": "string",
12
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
13
+ "description": "Project name. The config file is named <project>-api.config.json."
14
+ },
15
+ "target": {
16
+ "enum": ["react-native", "react", "next"],
17
+ "description": "react-native: uses @jutsustack/react-native-fetch. react / next: a generated fetch runtime."
18
+ },
19
+ "output": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "description": "Folder for generated files, relative to this config (must stay inside the project)."
23
+ },
24
+ "sources": {
25
+ "type": "array",
26
+ "minItems": 1,
27
+ "description": "Postman collections and Swagger / OpenAPI documents. Requests that are the same API (method + path) are merged.",
28
+ "items": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "required": ["id"],
32
+ "properties": {
33
+ "id": {
34
+ "type": "string",
35
+ "pattern": "^[A-Za-z0-9_-]+$",
36
+ "description": "Short unique id; names cache files and prefixes clashing model names."
37
+ },
38
+ "type": {
39
+ "enum": ["auto", "postman", "openapi", "swagger"],
40
+ "default": "auto",
41
+ "description": "auto detects the format from the content."
42
+ },
43
+ "path": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "description": "Local JSON / YAML file, relative to this config."
47
+ },
48
+ "url": {
49
+ "type": "string",
50
+ "pattern": "^https?://",
51
+ "description": "Remote document. Cached; re-downloaded only when its ETag / Last-Modified changes."
52
+ },
53
+ "postman": {
54
+ "type": "object",
55
+ "additionalProperties": false,
56
+ "required": ["collectionId"],
57
+ "description": "A collection in a Postman workspace, fetched with the Postman API.",
58
+ "properties": {
59
+ "collectionId": { "type": "string", "minLength": 1 },
60
+ "apiKeyEnv": {
61
+ "type": "string",
62
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
63
+ "default": "POSTMAN_API_KEY",
64
+ "description": "Environment variable holding the Postman API key."
65
+ }
66
+ }
67
+ },
68
+ "headers": {
69
+ "type": "object",
70
+ "additionalProperties": { "type": "string" },
71
+ "description": "Headers for url sources. ${ENV_VAR} is replaced from the environment, e.g. \"Bearer ${SPEC_TOKEN}\"."
72
+ },
73
+ "environment": {
74
+ "type": "string",
75
+ "minLength": 1,
76
+ "description": "Postman environment export used to resolve {{variables}} such as {{baseUrl}}."
77
+ }
78
+ },
79
+ "oneOf": [
80
+ { "required": ["path"] },
81
+ { "required": ["url"] },
82
+ { "required": ["postman"] }
83
+ ]
84
+ }
85
+ },
86
+ "baseUrl": {
87
+ "type": "string",
88
+ "description": "Base URL written into the client.ts scaffold (default: the first server found in the sources)."
89
+ },
90
+ "methods": {
91
+ "type": "array",
92
+ "minItems": 1,
93
+ "uniqueItems": true,
94
+ "items": {
95
+ "enum": ["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]
96
+ },
97
+ "default": ["GET", "POST", "PUT", "PATCH", "DELETE"]
98
+ },
99
+ "groupBy": {
100
+ "enum": ["folder", "tag", "path", "none"],
101
+ "default": "folder",
102
+ "description": "folder/tag: Postman folder or OpenAPI tag. path: first path segment. none: one group."
103
+ },
104
+ "hooks": {
105
+ "type": "boolean",
106
+ "default": true,
107
+ "description": "Generate React hooks (hooks.ts)."
108
+ },
109
+ "include": {
110
+ "type": "array",
111
+ "items": { "type": "string", "minLength": 1 },
112
+ "description": "Only endpoints matching one of these globs, e.g. \"/users/**\" or \"GET /orders/*\"."
113
+ },
114
+ "exclude": {
115
+ "type": "array",
116
+ "items": { "type": "string", "minLength": 1 },
117
+ "description": "Skip endpoints matching any of these globs."
118
+ },
119
+ "format": {
120
+ "enum": ["none", "prettier"],
121
+ "default": "none",
122
+ "description": "prettier: format output with the project's own prettier and config."
123
+ },
124
+ "importExtension": {
125
+ "enum": ["", ".js"],
126
+ "default": "",
127
+ "description": "Suffix for relative imports in generated code. Use \".js\" for NodeNext module resolution."
128
+ },
129
+ "cacheDir": {
130
+ "type": "string",
131
+ "minLength": 1,
132
+ "default": ".jutsu-api",
133
+ "description": "Cache folder (manifest + remote snapshots). Add it to .gitignore."
134
+ }
135
+ }
136
+ }