@bradleyhodges/addresskit 2.2.3 → 2.4.3

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 (4) hide show
  1. package/README.md +430 -156
  2. package/api/swagger.yaml +353 -0
  3. package/dist/cli.js +757 -2295
  4. package/package.json +17 -12
package/api/swagger.yaml CHANGED
@@ -15,6 +15,8 @@ basePath: '/'
15
15
  tags:
16
16
  - name: address
17
17
  description: Australian address lookup and autocomplete operations
18
+ - name: locality
19
+ description: Australian locality (suburb/postcode) lookup and autocomplete operations
18
20
  schemes:
19
21
  - 'https'
20
22
  - 'http'
@@ -186,6 +188,137 @@ paths:
186
188
  description: unexpected error
187
189
  schema:
188
190
  $ref: "#/definitions/JsonApiErrorDocument"
191
+ /localities:
192
+ get:
193
+ summary: Search Localities (Autocomplete)
194
+ operationId: getLocalities
195
+ x-swagger-router-controller: Localities
196
+ x-root-rel: localities
197
+ description: |
198
+ Searches for localities (suburbs/postcodes) matching the query string and returns
199
+ lightweight autocomplete suggestions optimized for typeahead UX.
200
+
201
+ Each result contains only the display text and locality ID. Use the
202
+ `/localities/{localityId}` endpoint to retrieve full locality details.
203
+
204
+ This endpoint is useful when you only need suburb/postcode lookups without
205
+ full address autocomplete.
206
+
207
+ Results are paginated using JSON:API pagination parameters.
208
+ tags:
209
+ - locality
210
+ parameters:
211
+ - name: q
212
+ in: query
213
+ description: |
214
+ Search query string. Supports fuzzy matching against locality names,
215
+ postcodes, and state abbreviations. Minimum 2 characters required.
216
+ type: string
217
+ minLength: 2
218
+ required: true
219
+ - name: page[number]
220
+ in: query
221
+ description: |
222
+ Page number for pagination (1-indexed). Defaults to 1.
223
+ type: integer
224
+ minimum: 1
225
+ required: false
226
+ - name: page[size]
227
+ in: query
228
+ description: |
229
+ Number of results per page. Defaults to 10, maximum 100.
230
+ type: integer
231
+ minimum: 1
232
+ maximum: 100
233
+ required: false
234
+ responses:
235
+ 200:
236
+ description: successful query
237
+ schema:
238
+ $ref: '#/definitions/LocalityAutocompleteDocument'
239
+ headers:
240
+ link:
241
+ description: RFC 5988 Links for pagination
242
+ type: array
243
+ collectionFormat: csv
244
+ items:
245
+ type: string
246
+ pattern: '<(.*)>;(.*)'
247
+ link-template:
248
+ description: RFC 6570 Link Templates
249
+ type: array
250
+ collectionFormat: csv
251
+ items:
252
+ type: string
253
+ pattern: '<(.*)>;(.*)'
254
+ 400:
255
+ description: invalid query parameters
256
+ schema:
257
+ $ref: '#/definitions/JsonApiErrorDocument'
258
+ 503:
259
+ description: service unavailable
260
+ schema:
261
+ $ref: "#/definitions/JsonApiErrorDocument"
262
+ 504:
263
+ description: gateway timeout
264
+ schema:
265
+ $ref: "#/definitions/JsonApiErrorDocument"
266
+ 500:
267
+ description: unexpected error
268
+ schema:
269
+ $ref: "#/definitions/JsonApiErrorDocument"
270
+ /localities/{localityId}:
271
+ get:
272
+ summary: Get Locality Details
273
+ operationId: getLocality
274
+ x-swagger-router-controller: Localities
275
+ description: |
276
+ Returns comprehensive details about a specific locality by its unique
277
+ G-NAF Locality Persistent Identifier (PID).
278
+
279
+ The response includes:
280
+ - Locality name and display format
281
+ - State/territory information
282
+ - All postcodes associated with the locality
283
+ - Locality classification
284
+ tags:
285
+ - locality
286
+ parameters:
287
+ - name: localityId
288
+ in: path
289
+ description: |
290
+ The unique G-NAF Locality Persistent Identifier (PID) for the locality.
291
+ Example: `NSW1234`
292
+ type: string
293
+ required: true
294
+ responses:
295
+ 200:
296
+ description: successful query
297
+ schema:
298
+ $ref: '#/definitions/LocalityDetailDocument'
299
+ headers:
300
+ link:
301
+ description: RFC 5988 Links
302
+ type: array
303
+ collectionFormat: csv
304
+ items:
305
+ type: string
306
+ pattern: '<(.*)>;(.*)'
307
+ ETag:
308
+ description: Entity tag for cache validation
309
+ type: string
310
+ 404:
311
+ description: locality not found
312
+ schema:
313
+ $ref: "#/definitions/JsonApiErrorDocument"
314
+ 503:
315
+ description: service unavailable
316
+ schema:
317
+ $ref: "#/definitions/JsonApiErrorDocument"
318
+ 500:
319
+ description: unexpected error
320
+ schema:
321
+ $ref: "#/definitions/JsonApiErrorDocument"
189
322
  definitions:
190
323
  # ============================================================================
191
324
  # JSON:API Core Types
@@ -261,6 +394,10 @@ definitions:
261
394
  type: integer
262
395
  description: Query processing time in milliseconds
263
396
  example: 45
397
+ warning:
398
+ type: string
399
+ description: Optional warning message (e.g., when dataset is empty or no results found)
400
+ example: No addresses matched your search query.
264
401
 
265
402
  JsonApiError:
266
403
  type: object
@@ -818,6 +955,222 @@ definitions:
818
955
  links:
819
956
  self: /addresses/GANT_718592778
820
957
 
958
+ # ============================================================================
959
+ # Locality Autocomplete Types
960
+ # ============================================================================
961
+ LocalityAutocompleteAttributes:
962
+ type: object
963
+ description: Minimal locality data for autocomplete suggestions
964
+ required:
965
+ - display
966
+ - rank
967
+ properties:
968
+ display:
969
+ type: string
970
+ description: Display name for the locality (e.g., "SYDNEY NSW 2000")
971
+ example: SYDNEY NSW 2000
972
+ rank:
973
+ type: number
974
+ format: float
975
+ description: Relevance score normalized to 0-1 range (1 = best match)
976
+ minimum: 0
977
+ maximum: 1
978
+ example: 0.95
979
+
980
+ LocalityAutocompleteResource:
981
+ type: object
982
+ description: JSON:API resource for a locality autocomplete suggestion
983
+ required:
984
+ - type
985
+ - id
986
+ - attributes
987
+ properties:
988
+ type:
989
+ type: string
990
+ enum: [locality-suggestion]
991
+ description: Resource type identifier
992
+ example: locality-suggestion
993
+ id:
994
+ type: string
995
+ description: Unique locality identifier (G-NAF Locality PID)
996
+ example: NSW1234
997
+ attributes:
998
+ $ref: '#/definitions/LocalityAutocompleteAttributes'
999
+ links:
1000
+ type: object
1001
+ properties:
1002
+ self:
1003
+ type: string
1004
+ description: Link to full locality details
1005
+ example: /localities/NSW1234
1006
+
1007
+ LocalityAutocompleteDocument:
1008
+ type: object
1009
+ description: JSON:API document containing locality autocomplete results
1010
+ required:
1011
+ - data
1012
+ properties:
1013
+ jsonapi:
1014
+ $ref: '#/definitions/JsonApiVersion'
1015
+ data:
1016
+ type: array
1017
+ items:
1018
+ $ref: '#/definitions/LocalityAutocompleteResource'
1019
+ description: Array of locality autocomplete suggestion resources
1020
+ links:
1021
+ $ref: '#/definitions/JsonApiLinks'
1022
+ meta:
1023
+ $ref: '#/definitions/JsonApiMeta'
1024
+ example:
1025
+ jsonapi:
1026
+ version: "1.1"
1027
+ data:
1028
+ - type: locality-suggestion
1029
+ id: NSW1234
1030
+ attributes:
1031
+ display: SYDNEY NSW 2000
1032
+ rank: 1
1033
+ links:
1034
+ self: /localities/NSW1234
1035
+ - type: locality-suggestion
1036
+ id: NSW5678
1037
+ attributes:
1038
+ display: SYDNEY SOUTH NSW 2000
1039
+ rank: 0.85
1040
+ links:
1041
+ self: /localities/NSW5678
1042
+ links:
1043
+ self: /localities?q=sydney
1044
+ first: /localities?q=sydney
1045
+ prev: null
1046
+ next: /localities?q=sydney&page[number]=2
1047
+ last: /localities?q=sydney&page[number]=5
1048
+ meta:
1049
+ total: 42
1050
+ page: 1
1051
+ pageSize: 10
1052
+ totalPages: 5
1053
+
1054
+ # ============================================================================
1055
+ # Locality Detail Types
1056
+ # ============================================================================
1057
+ LocalityClass:
1058
+ type: object
1059
+ description: Locality classification
1060
+ properties:
1061
+ code:
1062
+ type: string
1063
+ example: G
1064
+ maxLength: 1
1065
+ name:
1066
+ type: string
1067
+ example: GAZETTED LOCALITY
1068
+ maxLength: 50
1069
+
1070
+ LocalityDetailAttributes:
1071
+ type: object
1072
+ description: Complete locality details
1073
+ required:
1074
+ - localityPid
1075
+ - name
1076
+ - display
1077
+ properties:
1078
+ localityPid:
1079
+ type: string
1080
+ description: G-NAF Locality Persistent Identifier
1081
+ example: NSW1234
1082
+ name:
1083
+ type: string
1084
+ description: Locality name (suburb or town name)
1085
+ example: SYDNEY
1086
+ maxLength: 100
1087
+ display:
1088
+ type: string
1089
+ description: Display name including state and postcode
1090
+ example: SYDNEY NSW 2000
1091
+ class:
1092
+ $ref: '#/definitions/LocalityClass'
1093
+ state:
1094
+ $ref: '#/definitions/AddressState'
1095
+ postcode:
1096
+ type: string
1097
+ pattern: '^\d{4}$'
1098
+ example: '2000'
1099
+ description: Primary Australian 4-digit postcode for this locality
1100
+ postcodes:
1101
+ type: array
1102
+ items:
1103
+ type: string
1104
+ pattern: '^\d{4}$'
1105
+ description: All postcodes associated with this locality
1106
+ example: ['2000', '2001']
1107
+
1108
+ LocalityDetailResource:
1109
+ type: object
1110
+ description: JSON:API resource for a detailed locality
1111
+ required:
1112
+ - type
1113
+ - id
1114
+ - attributes
1115
+ properties:
1116
+ type:
1117
+ type: string
1118
+ enum: [locality]
1119
+ description: Resource type identifier
1120
+ example: locality
1121
+ id:
1122
+ type: string
1123
+ description: Unique locality identifier (G-NAF Locality PID)
1124
+ example: NSW1234
1125
+ attributes:
1126
+ $ref: '#/definitions/LocalityDetailAttributes'
1127
+ links:
1128
+ type: object
1129
+ properties:
1130
+ self:
1131
+ type: string
1132
+ description: Self-referential link
1133
+ example: /localities/NSW1234
1134
+
1135
+ LocalityDetailDocument:
1136
+ type: object
1137
+ description: JSON:API document containing detailed locality information
1138
+ required:
1139
+ - data
1140
+ properties:
1141
+ jsonapi:
1142
+ $ref: '#/definitions/JsonApiVersion'
1143
+ data:
1144
+ $ref: '#/definitions/LocalityDetailResource'
1145
+ links:
1146
+ type: object
1147
+ properties:
1148
+ self:
1149
+ type: string
1150
+ example: /localities/NSW1234
1151
+ example:
1152
+ jsonapi:
1153
+ version: "1.1"
1154
+ data:
1155
+ type: locality
1156
+ id: NSW1234
1157
+ attributes:
1158
+ localityPid: NSW1234
1159
+ name: SYDNEY
1160
+ display: SYDNEY NSW 2000
1161
+ class:
1162
+ code: G
1163
+ name: GAZETTED LOCALITY
1164
+ state:
1165
+ name: New South Wales
1166
+ abbreviation: NSW
1167
+ postcode: '2000'
1168
+ postcodes: ['2000', '2001']
1169
+ links:
1170
+ self: /localities/NSW1234
1171
+ links:
1172
+ self: /localities/NSW1234
1173
+
821
1174
  # ============================================================================
822
1175
  # Root Types
823
1176
  # ============================================================================