Skip to content

Commit 3f89648

Browse files
author
Ryan Marsh
authored
docs: replace record with type (sam-goodwin#150)
1 parent dbbd128 commit 3f89648

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Furthermore, its interface is higher-level than what would normally be expected
6868
/**
6969
* Message is a JSON Object with properties: `key`, `count` and `timestamp`.
7070
*/
71-
class NotificationRecord extends Record({
71+
class NotificationRecord extends Type({
7272
key: string,
7373
count: integer,
7474
timestamp
@@ -90,7 +90,7 @@ This feature in punchcard becomes even more evident when using DynamoDB. To demo
9090

9191
```ts
9292
// class describing the data in the DynamoDB Table
93-
class TableRecord extends Record({
93+
class TableRecord extends Type({
9494
id: string,
9595
count: integer
9696
.apply(Minimum(0))
@@ -195,7 +195,7 @@ const queue = topic.toSQSQueue(stack, 'MyNewQueue');
195195
We can then, perhaps, `map` over each message in the `Queue` and collect the results into a new AWS Kinesis `Stream`:
196196

197197
```ts
198-
class LogDataRecord extends Record({
198+
class LogDataRecord extends Type({
199199
key: string,
200200
count: integer,
201201
tags: array(string)

docs/4-shapes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Data structures in punchcard are like ordinary collections such as an `Array<T>`
44
Shapes are an in-code abstraction for (and agnostic to) data and schema formats such as JSON Schema, Glue Tables, DynamoDB, and (soon) Avro, Protobuf, Parquet, Orc.
55

66
```ts
7-
class NotificationRecord extends Record({
7+
class NotificationRecord extends Type({
88
key: string,
99
count: integer
1010
.apply(Minimum(0)), // apply a Trait to constrain the value of this integer
@@ -51,7 +51,7 @@ The framework makes use of Shapes to type-check your code against its schema and
5151

5252
For reference, the above Topic's Shape:
5353
```ts
54-
class NotificationRecord extends Record({
54+
class NotificationRecord extends Type({
5555
key: string,
5656
count: integer
5757
.apply(Minimum(0)),

docs/5-dynamodb-dsl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Punchcard uses TypeScript's [Advanced Types](https://www.typescriptlang.org/docs
44

55
To demonstrate, let's create a `DynamoDB.Table` "with some Shape":
66
```ts
7-
class TableRecord extends Record({
7+
class TableRecord extends Type({
88
id: string,
99
count: integer
1010
}) {}

docs/6-stream-processing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Data structures that implement `Stream` are: `SNS.Topic`, `SQS.Queue`, `Kinesis.
66

77
Given an `SNS.Topic`:
88
```ts
9-
class NotificationRecord extends Record({
9+
class NotificationRecord extends Type({
1010
key: string,
1111
count: integer,
1212
timestamp
@@ -43,7 +43,7 @@ These functions are called `Collectors` and they follow the naming convention `t
4343
We can then, perhaps, `map` over each message in the `Queue` and collect the results into a new AWS Kinesis `Stream`:
4444

4545
```ts
46-
class StreamDataRecord extends Record({
46+
class StreamDataRecord extends Type({
4747
key: string,
4848
count: integer,
4949
tags: array(string),

packages/@punchcard/shape-dynamodb/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This library extends the Punchcard Shape Type-System to provide a high-level abs
77
The type of data in a Table is defined as a class with properties that represent its "Shape".
88

99
```ts
10-
class Type extends Record({
10+
class Type extends Type({
1111
key: string;
1212
count: number;
1313
list: array(string);

packages/@punchcard/shape-hive/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# @punchcard/shape-hive
22

3-
Maps a Punchcard Shape Record to its corresponding Hive Schema compatible with AWS Glue.
3+
Maps a Punchcard Shape Type to its corresponding Hive Schema compatible with AWS Glue.
44

5-
# Define a Schema with a Record
5+
# Define a Schema with a Type
66

77
```ts
88
import { string, integer, number, array, set, map, Description } from '@punchcard/shape';
@@ -11,11 +11,11 @@ import { string, integer, number, array, set, map, Description } from '@punchcar
1111
import { double, float, char, varchar, Glue } from '@punchcard/shape-hive';
1212

1313
// a record to be used within our top-level type (i.e. a nested structure).
14-
class Nested extends Record({
14+
class Nested extends Type({
1515
name: string
1616
}) {}
1717

18-
class Data extends Record({
18+
class Data extends Type({
1919
id: string
2020
.apply(Description('this is a comment')),
2121

packages/@punchcard/shape-json/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Provides JSON serialization and deserialization for Punchcard Shapes.
44

5-
# Create a Record
5+
# Create a Type
66

77
```ts
8-
class MyType extends Record({
8+
class MyType extends Type({
99
key: string
1010
.apply(MinLength(1)), // apply constraints with Traits
1111
count: integer

packages/@punchcard/shape-jsonpath/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ This library extends the Punchcard Shape Type-System with support for a type-saf
55
# Define a Type
66
```ts
77
// a record to be used within our top-level type (i.e. a nested structure).
8-
export class Nested extends Record({
8+
export class Nested extends Type({
99
/**
1010
* This is a nested string.
1111
*/
1212
a: string
1313
}) {}
1414

1515
// the type we will query with JSON path
16-
export class MyType extends Record({
16+
export class MyType extends Type({
1717
/**
1818
* Field documentation.
1919
*/

packages/@punchcard/shape-jsonschema/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This library maps types in the Punchcard Shape type-system to a JSON Schema.
44

55
# Defining Types
66

7-
First, create a Record using the Shape type-sytem:
7+
First, create a Type using the Shape type-sytem:
88
```ts
9-
class MyType extends Record({
9+
class MyType extends Type({
1010
key: string
1111
.apply(MinLength(1)),
1212
count: integer

packages/@punchcard/shape/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Punchcard Shapes is another workaround, except it eliminates the above redundanc
5454
Types are constructed in the same way as ordinary data in JavaScript!
5555

5656
```ts
57-
class MyType extends Record({
57+
class MyType extends Type({
5858
/**
5959
* In-line documentation goes here.
6060
*/
@@ -102,7 +102,7 @@ What about decorators though?
102102
Decorators in TypeScript can only be declared on top-level declarations, so we can not apply them to the arguments passed in to `Record`:
103103

104104
```ts
105-
class MyType extends Record({
105+
class MyType extends Type({
106106
@Decorator() // not possible, bummer
107107
items: array(string)
108108
}) {}
@@ -111,7 +111,7 @@ class MyType extends Record({
111111
To use ordinary decorators, you must redundantly declare the member:
112112

113113
```ts
114-
class MyType extends Record({
114+
class MyType extends Type({
115115
items: array(string)
116116
}) {
117117
@Decorator() // possible
@@ -124,7 +124,7 @@ This is unfortunate, but it is par for the course when compared to the `type-gra
124124
To eiminate this redundancy, Shapes also provide its own decorator replacement called "Traits". Any Shape can have a trait "applied" to it:
125125

126126
```ts
127-
class MyType extends Record({
127+
class MyType extends Type({
128128
items: array(string)
129129
.apply(Trait())
130130
}) {}
@@ -135,7 +135,7 @@ Traits take decorators even further, however, as they can also augment the type-
135135
For example, the minimum value of an integer can be annotated on the type and used in type-level machinery to change behavior:
136136

137137
```ts
138-
class MyType extends Record({
138+
class MyType extends Type({
139139
myNumber: integer
140140
.apply(Minimum(0))
141141
}) {}
@@ -164,7 +164,7 @@ Traits are used to annotate records with validation information. Common use-case
164164

165165
### `Optional` - mark a member as optional, equivalent to `?` in TS.
166166
```ts
167-
class MyType extends Record({
167+
class MyType extends Type({
168168
key: string.apply(Optional),
169169
// or use short-hand
170170
shortHand: optional(string)
@@ -178,7 +178,7 @@ const myType = new MyType({}); // still compiles if we don't provide a value for
178178

179179
### Min/Max numbers
180180
```ts
181-
class MyType extends Record({
181+
class MyType extends Type({
182182
myNumber: number
183183
.apply(Minimum(0))
184184
.apply(Maximum(256))
@@ -187,7 +187,7 @@ class MyType extends Record({
187187

188188
### Min/Max length of a string
189189
```ts
190-
class MyType extends Record({
190+
class MyType extends Type({
191191
myNumber: string
192192
.apply(MinLength(0))
193193
.apply(MaxLength(256))
@@ -212,5 +212,5 @@ class MyType extends Record({
212212
* `set(T)` - a set of items, equivalent to `Set<T>` in TS, but also supports a non-primitive `T`.
213213
* `map(T)` - a map of string keys to values, equivalent to `{[key: string]: T; }` in TS.
214214

215-
## Record
216-
* `Record(M)` - a class with named and well-typed members:
215+
## Type
216+
* `Type(M)` - a class with named and well-typed members:

0 commit comments

Comments
 (0)