-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4,953 changed files
with
248,612 additions
and
6,251 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
name: seed | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
@@ -24,6 +27,7 @@ jobs: | |
typescript: ${{ steps.filter.outputs.typescript }} | ||
go: ${{ steps.filter.outputs.go }} | ||
csharp: ${{ steps.filter.outputs.csharp }} | ||
php: ${{ steps.filter.outputs.php }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: dorny/paths-filter@v2 | ||
|
@@ -69,7 +73,10 @@ jobs: | |
- 'generators/csharp/**' | ||
- seed/csharp-sdk/seed.yml | ||
- seed/csharp-model/seed.yml | ||
php: | ||
- 'generators/php/**' | ||
- seed/php-sdk/seed.yml | ||
- seed/php-model/seed.yml | ||
ruby-model: | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
|
@@ -617,3 +624,65 @@ jobs: | |
- name: Ensure no changes to git-tracked files | ||
run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" | ||
|
||
php-model: | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: ${{ needs.changes.outputs.php == 'true' || needs.changes.outputs.seed == 'true' }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
uses: ./.github/actions/install | ||
|
||
- uses: bufbuild/[email protected] | ||
with: | ||
github_token: ${{ github.token }} | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "stable" | ||
|
||
- name: Install protoc-gen-openapi | ||
run: go install github.com/google/gnostic/cmd/[email protected] | ||
|
||
- name: Seed Test | ||
env: | ||
FORCE_COLOR: "2" | ||
run: | | ||
pnpm seed:local test --generator php-model --parallel 16 | ||
- name: Ensure no changes to git-tracked files | ||
run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" | ||
|
||
php-sdk: | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: ${{ needs.changes.outputs.php == 'true' || needs.changes.outputs.seed == 'true' }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
uses: ./.github/actions/install | ||
|
||
- uses: bufbuild/[email protected] | ||
with: | ||
github_token: ${{ github.token }} | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "stable" | ||
|
||
- name: Install protoc-gen-openapi | ||
run: go install github.com/google/gnostic/cmd/[email protected] | ||
|
||
- name: Seed Test | ||
env: | ||
FORCE_COLOR: "2" | ||
run: | | ||
pnpm seed:local test --generator php-sdk --parallel 16 | ||
- name: Ensure no changes to git-tracked files | ||
run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,45 @@ | ||
FROM node:lts-slim as base | ||
FROM node:lts-slim | ||
|
||
FROM base AS builder | ||
RUN yarn add \ | ||
# jest | ||
jest@29.7.0 \ | ||
@types/jest@29.5.5 \ | ||
# node fetch | ||
node-fetch@2.7.0 \ | ||
@types/node-fetch@2.6.9 \ | ||
# node | ||
@types/node@17.0.33 \ | ||
# qs | ||
qs@6.11.2 \ | ||
@types/qs@6.9.8 \ | ||
# url join | ||
url-join@4.0.1 \ | ||
@types/url-join@4.0.1 \ | ||
# readable stream | ||
readable-stream@4.5.2 \ | ||
@types/readable-stream@4.0.15 \ | ||
# form data | ||
form-data@4.0.0 \ | ||
# formdata-node | ||
formdata-node@6.0.3 \ | ||
# jest env jsdom | ||
jest-environment-jsdom@29.7.0 \ | ||
# js base64 | ||
"[email protected]" \ | ||
# prettier | ||
prettier@2.7.1 \ | ||
# ts jest | ||
ts-jest@29.1.1 \ | ||
# typescript | ||
"[email protected]" \ | ||
# form data encoder | ||
form-data-encoder@4.0.2 \ | ||
# webpack | ||
ts-loader@9.3.1 \ | ||
webpack@5.94.0 \ | ||
# fetch mock jest | ||
fetch-mock-jest@1.5.1 | ||
|
||
RUN mkdir /yarn-cache-template | ||
RUN yarn config set cache-folder /yarn-cache-template | ||
RUN yarn add \ | ||
@types/jest@29.5.5 \ | ||
@types/node-fetch@2.6.9 \ | ||
@types/node@17.0.33 \ | ||
@types/qs@6.9.8 \ | ||
@types/url-join@4.0.1 \ | ||
form-data@4.0.0 \ | ||
jest-environment-jsdom@29.7.0 \ | ||
jest@29.7.0 \ | ||
js-base64@3.7.2 \ | ||
node-fetch@2.7.0 \ | ||
prettier@2.7.1 \ | ||
qs@6.11.2 \ | ||
ts-jest@29.1.1 \ | ||
typescript@4.6.4 \ | ||
url-join@4.0.1 | ||
|
||
FROM base AS runner | ||
|
||
COPY --from=builder /yarn-cache-template /yarn-cache-template | ||
# Installs tsc | ||
RUN npm install -g typescript | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AbstractAstNode } from "./AbstractAstNode"; | ||
|
||
export type Argument = NamedArgument | UnnamedArgument; | ||
|
||
export type Arguments = NamedArgument[] | UnnamedArgument[]; | ||
|
||
export interface NamedArgument { | ||
name: string; | ||
assignment: AbstractAstNode; | ||
} | ||
|
||
export type UnnamedArgument = AbstractAstNode; | ||
|
||
export function isNamedArgument(argument: NamedArgument | UnnamedArgument): argument is NamedArgument { | ||
return (argument as NamedArgument)?.name != null; | ||
} | ||
|
||
export function hasNamedArgument(arguments_: Arguments): boolean { | ||
return arguments_.length > 0 && arguments_[0] != null && isNamedArgument(arguments_[0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export { AbstractAstNode } from "./AbstractAstNode"; | ||
export { AbstractWriter } from "./AbstractWriter"; | ||
export { CodeBlock } from "./CodeBlock"; | ||
export { | ||
type Argument, | ||
type Arguments, | ||
type NamedArgument, | ||
type UnnamedArgument, | ||
hasNamedArgument, | ||
isNamedArgument | ||
} from "./Argument"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { getPackageName } from "./getPackageName"; | ||
export { getSdkVersion } from "./getSdkVersion"; | ||
export { parseGeneratorConfig } from "./parseGeneratorConfig"; | ||
export { parseIR } from "./parseIR"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { AbsoluteFilePath, streamObjectFromFile } from "@fern-api/fs-utils"; | ||
|
||
export declare namespace parseIR { | ||
export interface Args<IntermediateRepresentation> { | ||
absolutePathToIR: AbsoluteFilePath; | ||
parse: (raw: unknown, opts?: SchemaOptions) => MaybePromise<MaybeValid<IntermediateRepresentation>>; | ||
} | ||
|
||
/* Copy some types across the IR SDKs */ | ||
export type MaybePromise<T> = T | Promise<T>; | ||
|
||
export type MaybeValid<T> = Valid<T> | Invalid; | ||
|
||
export interface Valid<T> { | ||
ok: true; | ||
value: T; | ||
} | ||
|
||
export interface Invalid { | ||
ok: false; | ||
errors: unknown[]; | ||
} | ||
|
||
interface SchemaOptions { | ||
/** | ||
* how to handle unrecognized keys in objects | ||
* | ||
* @default "fail" | ||
*/ | ||
unrecognizedObjectKeys?: "fail" | "passthrough" | "strip"; | ||
/** | ||
* whether to fail when an unrecognized discriminant value is | ||
* encountered in a union | ||
* | ||
* @default false | ||
*/ | ||
allowUnrecognizedUnionMembers?: boolean; | ||
/** | ||
* whether to fail when an unrecognized enum value is encountered | ||
* | ||
* @default false | ||
*/ | ||
allowUnrecognizedEnumValues?: boolean; | ||
/** | ||
* whether to allow data that doesn't conform to the schema. | ||
* invalid data is passed through without transformation. | ||
* | ||
* when this is enabled, .parse() and .json() will always | ||
* return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()` | ||
* will never fail. | ||
* | ||
* @default false | ||
*/ | ||
skipValidation?: boolean; | ||
/** | ||
* each validation failure contains a "path" property, which is | ||
* the breadcrumbs to the offending node in the JSON. you can supply | ||
* a prefix that is prepended to all the errors' paths. this can be | ||
* helpful for zurg's internal debug logging. | ||
*/ | ||
breadcrumbsPrefix?: string[]; | ||
} | ||
} | ||
|
||
export async function parseIR<IR>({ absolutePathToIR, parse }: parseIR.Args<IR>): Promise<IR> { | ||
const irJson = await streamObjectFromFile(absolutePathToIR); | ||
// eslint-disable-next-line no-console | ||
console.log(`Parsed ${absolutePathToIR}`); | ||
const parsedIR = await parse(irJson, { | ||
unrecognizedObjectKeys: "passthrough", | ||
allowUnrecognizedEnumValues: true, | ||
allowUnrecognizedUnionMembers: true | ||
}); | ||
|
||
if (!parsedIR.ok) { | ||
// eslint-disable-next-line no-console | ||
console.log(`Failed to parse ${absolutePathToIR}`); | ||
throw new Error(`Failed to parse IR: ${parsedIR.errors}`); | ||
} | ||
|
||
return parsedIR.value; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.