Skip to content

Commit aba46c9

Browse files
committed
Merge branch 'release/v0.28.3'
2 parents 11e6c21 + 6dcc95e commit aba46c9

13 files changed

Lines changed: 24 additions & 115 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zeed",
33
"type": "module",
4-
"version": "0.28.2",
4+
"version": "0.28.3",
55
"packageManager": "pnpm@10.8.1",
66
"description": "🌱 Simple foundation library",
77
"author": {

src/common/schema/export-swift.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe('swift.spec', () => {
99
aBool: boolean(),
1010
aNumber: number(),
1111
aString: string(),
12+
}).props({
13+
swiftName: 'Test123',
14+
swiftProtocol: 'Codable',
1215
})
1316

1417
type t = Infer<typeof schema>
@@ -19,10 +22,10 @@ describe('swift.spec', () => {
1922
aString: string
2023
}>()
2124

22-
const r = schemaExportSwiftStruct(schema, 'Test')
25+
const r = schemaExportSwiftStruct(schema)
2326

2427
expect(r).toMatchInlineSnapshot(`
25-
"struct Test {
28+
"struct Test123: Codable {
2629
var anInt: Int? = 0
2730
var aBool: Bool
2831
var aNumber: Double

src/common/schema/export-swift.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { assert } from '../assert'
33
import { objectMap } from '../data/object'
44
import { isSchemaObjectFlat } from './utils'
55

6-
// declare module './schema' {
7-
// interface TypeProps {
8-
// argShort?: string
9-
// argDesc?: string
10-
// }
11-
// }
6+
declare module './schema' {
7+
interface TypeProps {
8+
swiftName?: string
9+
swiftProtocol?: string
10+
}
11+
}
1212

1313
const mapSwiftType = {
1414
string: 'String',
@@ -20,8 +20,13 @@ const mapSwiftType = {
2020
export function schemaExportSwiftStruct<T>(schema: Type<T>, name: string = 'Example'): string {
2121
assert(isSchemaObjectFlat(schema), 'schema should be a flat object')
2222

23+
let protocol = ''
24+
if (schema._props?.swiftProtocol) {
25+
protocol = `: ${schema._props.swiftProtocol}`
26+
}
27+
2328
const lines: string[] = [
24-
`struct ${name} {`,
29+
`struct ${schema._props?.swiftName ?? name}${protocol} {`,
2530
]
2631

2732
objectMap(schema._object!, (key, schema: Type<any>) => {

src/common/schema/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
export * from './args'
2-
export * from './env'
31
export * from './export-swift'
42
export * from './export-typescript'
3+
export * from './parse-args'
4+
export * from './parse-env'
55
export * from './schema'
6+
export * from './type-test'
67
export * from './utils'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Infer } from './schema'
2-
import { helpSchemaArgs, parseSchemaArgs } from './args'
2+
import { helpSchemaArgs, parseSchemaArgs } from './parse-args'
33
import { boolean, number, object } from './schema'
44

55
describe('args.spec', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Infer } from './schema'
2-
import { parseSchemaEnv, stringFromSchemaEnv } from './env'
2+
import { parseSchemaEnv, stringFromSchemaEnv } from './parse-env'
33
import { boolean, number, object, string } from './schema'
44

55
describe('env.spec', () => {

src/common/schema/sandbox-inherit.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/common/schema/sandbox.spec.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)