From 0cd7ec8b226dd7c7a90d86bacd49365ac67c3d36 Mon Sep 17 00:00:00 2001 From: RustamRu Date: Sun, 17 Nov 2024 18:06:55 +0300 Subject: [PATCH] feat: create success stubs json with type generation (#33) --- package-lock.json | 102 ++++++++++++++++--- package.json | 1 + stubs/json/landing/landing-success.json | 27 +++++ stubs/json/landing/landing-success.json.d.ts | 28 +++++ 4 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 stubs/json/landing/landing-success.json create mode 100644 stubs/json/landing/landing-success.json.d.ts diff --git a/package-lock.json b/package-lock.json index 93317ed..acfeaef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "eslint-plugin-react": "^7.37.2", "globals": "^15.11.0", "prettier": "3.3.3", + "ts-json-as-const": "^1.0.7", "typescript-eslint": "^8.12.2" } }, @@ -2864,6 +2865,13 @@ "react": ">=18" } }, + "node_modules/@dfoverdx/tocamelcase": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@dfoverdx/tocamelcase/-/tocamelcase-1.0.7.tgz", + "integrity": "sha512-QDlMJqwcE4eVCvxxQXp8nh7Nw9m5VQHPCAiyTD+W86Tl89VGhVJRb//RJRZKpn5A/Bq3EQNYDYlepurQ805MOQ==", + "dev": true, + "license": "ISC" + }, "node_modules/@emotion/babel-plugin": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.12.0.tgz", @@ -6958,20 +6966,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -7043,6 +7037,13 @@ "node": ">=6" } }, + "node_modules/get-own-enumerable-property-symbols": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", + "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", + "dev": true, + "license": "ISC" + }, "node_modules/get-symbol-description": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz", @@ -7839,6 +7840,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-obj": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-3.0.0.tgz", + "integrity": "sha512-IlsXEHOjtKhpN8r/tRFj2nDyTmHvcfNeu/nrRIcXE17ROeatXchkojffa1SpdqW4cr/Fj6QkEf/Gn4zf6KKvEQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-path-cwd": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", @@ -7901,6 +7915,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-regexp": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-3.1.0.tgz", + "integrity": "sha512-rbku49cWloU5bSMI+zaRaXdQHXnthP6DZ/vLnfdSKyL4zUzuWnomtOEiZZOd+ioQ+avFo/qau3KPTc7Fjy1uPA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-root": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-root/-/is-root-2.1.0.tgz", @@ -8049,6 +8076,19 @@ "dev": true, "license": "MIT" }, + "node_modules/isbinaryfile": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -10404,6 +10444,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/stringify-object": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-4.0.1.tgz", + "integrity": "sha512-qpV1FBpN0R1gDAhCHIU71SYGZb35Te+gOQbQ6lYRmVJT7pF1NB8mkHeEJvyYNiHXw+fB4KIbeIjQl1rgiIijiA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "get-own-enumerable-property-symbols": "^3.0.2", + "is-obj": "^3.0.0", + "is-regexp": "^3.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -10704,6 +10759,25 @@ "typescript": ">=4.2.0" } }, + "node_modules/ts-json-as-const": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ts-json-as-const/-/ts-json-as-const-1.0.7.tgz", + "integrity": "sha512-UMM24g4uBevqBuEqeMUNm2yBEd6VrpJt2hhGWSpmr3nGuhQYwYcLpmxUjsAh5qxJbafF+ICrHvOvHn16zh9Ojg==", + "dev": true, + "license": "ISC", + "dependencies": { + "@dfoverdx/tocamelcase": "^1.0.7", + "isbinaryfile": "^4.0.8", + "json5": "^2.2.0", + "stringify-object": "^4.0.0" + }, + "bin": { + "ts-json-as-const": "index.js" + }, + "peerDependencies": { + "typescript": ">=3" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", diff --git a/package.json b/package.json index 5b5ff92..652db04 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "eslint-plugin-react": "^7.37.2", "globals": "^15.11.0", "prettier": "3.3.3", + "ts-json-as-const": "^1.0.7", "typescript-eslint": "^8.12.2" } } diff --git a/stubs/json/landing/landing-success.json b/stubs/json/landing/landing-success.json new file mode 100644 index 0000000..d6ca8b6 --- /dev/null +++ b/stubs/json/landing/landing-success.json @@ -0,0 +1,27 @@ +{ + "success": true, + "body": { + "hero-section": { + "headline": "hero-section.headline", + "description": "hero-section.description", + "video": "demo.mp4" + }, + "sections": [ + { + "type": "benefits-section", + "heading": "benefits-section.heading", + "description": "benefits-section.description", + "list": [ + "benefits-section.list.0", + "benefits-section.list.1", + "benefits-section.list.2", + "benefits-section.list.3" + ] + }, + { + "type": "social-proof-section", + "heading": "social-proof-section.heading" + } + ] + } +} \ No newline at end of file diff --git a/stubs/json/landing/landing-success.json.d.ts b/stubs/json/landing/landing-success.json.d.ts new file mode 100644 index 0000000..7197ccf --- /dev/null +++ b/stubs/json/landing/landing-success.json.d.ts @@ -0,0 +1,28 @@ +interface LandingSuccess { + success: true, + body: { + 'hero-section': { + headline: 'hero-section.headline', + description: 'hero-section.description', + video: 'demo.mp4' + }, + sections: [ + { + type: 'benefits-section', + heading: 'benefits-section.heading', + description: 'benefits-section.description', + list: [ + 'benefits-section.list.0', + 'benefits-section.list.1', + 'benefits-section.list.2', + 'benefits-section.list.3' + ] + }, + {type: 'social-proof-section', heading: 'social-proof-section.heading'} + ] + } +} + +declare const LandingSuccess: LandingSuccess; + +export = LandingSuccess; \ No newline at end of file